New RuleChain object to replace previous nested array within StyleChooser
[potlatch2.git] / net / systemeD / halcyon / styleparser / RuleSet.as
index 33c20b9ce0bfb6c876cf1a256241fc1aacde9df4..0bf9923a472bdc835cb3394f94e2fd5459bdd248 100644 (file)
@@ -43,6 +43,7 @@ package net.systemeD.halcyon.styleparser {
                private static const CONDITION:RegExp   =/^ \[(.+?)\] \s* /sx;
                private static const OBJECT:RegExp              =/^ (\w+) \s* /sx;
                private static const DECLARATION:RegExp =/^ \{(.+?)\} \s* /sx;
                private static const CONDITION:RegExp   =/^ \[(.+?)\] \s* /sx;
                private static const OBJECT:RegExp              =/^ (\w+) \s* /sx;
                private static const DECLARATION:RegExp =/^ \{(.+?)\} \s* /sx;
+               private static const SUBPART:RegExp             =/^ ::(\S+) \s* /sx;
                private static const UNKNOWN:RegExp             =/^ (\S+) \s* /sx;
 
                private static const ZOOM_MINMAX:RegExp =/^ (\d+)\-(\d+) $/sx;
                private static const UNKNOWN:RegExp             =/^ (\S+) \s* /sx;
 
                private static const ZOOM_MINMAX:RegExp =/^ (\d+)\-(\d+) $/sx;
@@ -366,7 +367,7 @@ package net.systemeD.halcyon.styleparser {
                                        if (previous==oDECLARATION) { saveChooser(sc); sc=new StyleChooser(); }
 
                                        css=css.replace(CLASS,'');
                                        if (previous==oDECLARATION) { saveChooser(sc); sc=new StyleChooser(); }
 
                                        css=css.replace(CLASS,'');
-                                       sc.addCondition(new Condition('set',o[1]));
+                                       sc.currentChain.addConditionToLast(new Condition('set',o[1]));
                                        previous=oCONDITION;
 
                                // Not class - !.motorway, !.builtup, !:hover
                                        previous=oCONDITION;
 
                                // Not class - !.motorway, !.builtup, !:hover
@@ -374,30 +375,31 @@ package net.systemeD.halcyon.styleparser {
                                        if (previous==oDECLARATION) { saveChooser(sc); sc=new StyleChooser(); }
 
                                        css=css.replace(NOT_CLASS,'');
                                        if (previous==oDECLARATION) { saveChooser(sc); sc=new StyleChooser(); }
 
                                        css=css.replace(NOT_CLASS,'');
-                                       sc.addCondition(new Condition('unset',o[1]));
+                                       sc.currentChain.addConditionToLast(new Condition('unset',o[1]));
                                        previous=oCONDITION;
 
                                // Zoom
                                } else if ((o=ZOOM.exec(css))) {
                                        previous=oCONDITION;
 
                                // Zoom
                                } else if ((o=ZOOM.exec(css))) {
-                                       if (previous!=oOBJECT && previous!=oCONDITION) { sc.newObject(); }
+                                       if (previous!=oOBJECT && previous!=oCONDITION) { sc.currentChain.addRule(); }
 
                                        css=css.replace(ZOOM,'');
                                        var z:Array=parseZoom(o[1]);
 
                                        css=css.replace(ZOOM,'');
                                        var z:Array=parseZoom(o[1]);
-                                       sc.addZoom(z[0],z[1]);
+                                       sc.currentChain.addZoomToLast(z[0],z[1]);
+                                       sc.zoomSpecific=true;
                                        previous=oZOOM;
 
                                // Grouping - just a comma
                                } else if ((o=GROUP.exec(css))) {
                                        css=css.replace(GROUP,'');
                                        previous=oZOOM;
 
                                // Grouping - just a comma
                                } else if ((o=GROUP.exec(css))) {
                                        css=css.replace(GROUP,'');
-                                       sc.newGroup();
+                                       sc.newRuleChain();
                                        previous=oGROUP;
 
                                // Condition - [highway=primary]
                                } else if ((o=CONDITION.exec(css))) {
                                        if (previous==oDECLARATION) { saveChooser(sc); sc=new StyleChooser(); }
                                        previous=oGROUP;
 
                                // Condition - [highway=primary]
                                } else if ((o=CONDITION.exec(css))) {
                                        if (previous==oDECLARATION) { saveChooser(sc); sc=new StyleChooser(); }
-                                       if (previous!=oOBJECT && previous!=oZOOM && previous!=oCONDITION) { sc.newObject(); }
+                                       if (previous!=oOBJECT && previous!=oZOOM && previous!=oCONDITION) { sc.currentChain.addRule(); }
                                        css=css.replace(CONDITION,'');
                                        css=css.replace(CONDITION,'');
-                                       sc.addCondition(parseCondition(o[1]) as Condition);
+                                       sc.currentChain.addConditionToLast(parseCondition(o[1]) as Condition);
                                        previous=oCONDITION;
 
                                // Object - way, node, relation
                                        previous=oCONDITION;
 
                                // Object - way, node, relation
@@ -405,7 +407,7 @@ package net.systemeD.halcyon.styleparser {
                                        if (previous==oDECLARATION) { saveChooser(sc); sc=new StyleChooser(); }
 
                                        css=css.replace(OBJECT,'');
                                        if (previous==oDECLARATION) { saveChooser(sc); sc=new StyleChooser(); }
 
                                        css=css.replace(OBJECT,'');
-                                       sc.newObject(o[1]);
+                                       sc.currentChain.addRule(o[1]);
                                        previous=oOBJECT;
 
                                // Declaration - {...}
                                        previous=oOBJECT;
 
                                // Declaration - {...}