From 4b249f3b6f1beaa2300d9ee2afc8ca2468acc55b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 11 Sep 2006 16:18:07 +0000 Subject: [PATCH] * Support grouping of attributes into sections by using "###" comments. svn path=/nixpkgs/trunk/; revision=6493 --- maintainers/scripts/sort-attrs.str | 37 ++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/maintainers/scripts/sort-attrs.str b/maintainers/scripts/sort-attrs.str index 611521b0b4a4..621b67ec16f8 100644 --- a/maintainers/scripts/sort-attrs.str +++ b/maintainers/scripts/sort-attrs.str @@ -24,9 +24,19 @@ strategies no-wsp = !appl(prod([], cf(opt(layout())), no-attrs()), []) - + rules + list-sep(s): [] -> [] + list-sep(s): [x | xs] -> [[x | before] | [split | after]] + where + xs => (before, split, after) + list-sep(s): [x | xs] -> [[x | xs]] + where + xs + + + sort-attrs: appl(p@prod(_, _, attrs([term(cons("Attrs"))])), [ lit("{") @@ -36,18 +46,28 @@ rules , lit("}") ] ) -> - appl(p, [lit("{"), , appl(p2, attrs'), ws2, lit("}")]) + appl(p, [lit("{"), , appl(p2, attrs'), ws2, lit("}")]) where "found it"; - [ws1 | attrs] => groups; - groups => attrs'; + [ws1 | attrs] => withWSP; + withWSP => groups; + groups; + [x | xs]\ )> groups => attrs'; "did it" - group: [a, b | cs] -> [(a, b) | cs] - group: [] -> [] + attach-wsp: [a, b | cs] -> [(a, b) | cs] + attach-wsp: [] -> [] + + + starts-section: x@(appl(prod([cf(layout())], cf(opt(layout())), no-attrs()), cs), attr) -> x + where cs + + starts-section': [35, 35, 35 | cs] -> 1 + starts-section': [c | cs] -> cs + where c + - compare-attrs: x@ ( (_, appl(p1@prod(_, _, attrs([term(cons("Bind"))])), [id1 | xs1])) @@ -55,9 +75,6 @@ rules ) -> x where - "foo"; - id1; - id2; (id1, id2)