Changeset b32f7a496c511e07158f0d0752addedc2b378328

Show
Ignore:
Timestamp:
06/28/09 23:36:50 (15 months ago)
Author:
mb0 <mb0@…>
Children:
2aa064d78a2c1162da70e2413b7c386278a1473d
Parents:
1567fcce2711ee19e98902f8ef734f1a7dd9731f
git-author:
mb0 <mb0@…> (06/14/09 23:10:19)
git-committer:
mb0 <mb0@…> (06/28/09 23:36:50)
Message:

reworked lexer. lexer helper methods moved to as3 lex helper.
virtual semi insertion should now work reliable. the last lexer update was fubar. i forgot that the probe parser must be called for every token to work.
non-attribute soft keyword terminals are parsed more reliable.
the whole _abbrev and _full rule paths are not needed. we use simple semi insertion on '}' and EOF.
as alternate to _nosif there is now _sif. this change condenses the grammar and ast.
used copied lexer template that is not using deprecated methods.
regex and xml ast now have a common parent.

Files:
3 added
23 modified

Legend:

Unmodified
Added
Removed
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/BasicLexerTest.java

    r5eb830a rb32f7a4  
    5959 
    6060        private void assertTokens(IPrsStream lex, int[] kinds) throws Exception { 
    61                 assertEquals(2 + kinds.length, lex.getTokens().size()); 
    6261                for (int i = 0; i < kinds.length; i++) { 
    6362                        IToken token = lex.getTokenAt(i + 1); 
     
    8079 
    8180        public void testXml() throws Exception { 
     81                assertTokens(lex("<x"), new int[] { TK_LT, TK_IDENTIFIER}); 
    8282                assertToken(lex("<xml/>"), TK_Xml); 
    8383                assertToken(lex("<{tag} {attr}={value}/>"), TK_Xml); 
     
    9090                assertToken(lex("/"), TK_DIV); 
    9191                assertToken(lex("/="), TK_DIV_ASSIGN); 
     92                assertTokens(lex("/b;"), new int[] { TK_DIV, TK_IDENTIFIER, TK_SEMI }); 
    9293                assertTokens(lex("/=b;"), new int[] { TK_DIV_ASSIGN, TK_IDENTIFIER, 
    9394                                TK_SEMI }); 
    94                 assertTokens(lex("/b;"), new int[] { TK_DIV, TK_IDENTIFIER, TK_SEMI }); 
    9595        } 
    9696 
    9797        public void testRegex() throws Exception { 
    98                 assertTokens(lex("/[^\"|^>](http:\\/\\/+[\\S]*)/"), new int[] { 
    99                                 TK_DIV_RX, TK_RegularExpression }); 
     98                assertToken(lex("/[^\"|^>](http:\\/\\/+[\\S]*)/"), TK_RegularExpression); 
    10099                assertTokens( 
    101100                                lex("/^[a-z][\\w.-]+@\\w[\\w.-]+\\.[\\w.-]*[a-z][a-z]$/ig;"), 
    102                                 new int[] { TK_DIV_RX, TK_RegularExpression, TK_SEMI }); 
    103                 assertTokens(lex("/=/;"), new int[] { TK_DIV_RX, TK_RegularExpression, 
    104                                 TK_SEMI }); 
     101                                new int[] { TK_RegularExpression, TK_SEMI }); 
     102                assertTokens(lex("/=/;"), new int[] { TK_RegularExpression, TK_SEMI }); 
    105103                assertTokens(lex("var i=/=/;"), new int[] { TK_var, TK_IDENTIFIER, 
    106                                 TK_ASSIGN, TK_DIV_RX, TK_RegularExpression, TK_SEMI }); 
    107                 assertTokens(lex("/=/ while(true)\ntest();"), new int[] { TK_DIV_RX, 
    108                                 TK_RegularExpression, TK_while, TK_LPAREN, TK_true, TK_RPAREN, 
     104                                TK_ASSIGN, TK_RegularExpression, TK_SEMI }); 
     105                assertTokens(lex("/=/;while(true)\ntest();"), new int[] { 
     106                                TK_RegularExpression, TK_SEMI, TK_while, TK_LPAREN, TK_true, TK_RPAREN, 
    109107                                TK_IDENTIFIER, TK_LPAREN, TK_RPAREN, TK_SEMI }); 
    110108                assertTokens( 
    111109                                lex("var i=/=/\nwhile(true)\ntest();"), 
    112                                 new int[] { TK_var, TK_IDENTIFIER, TK_ASSIGN, TK_DIV_RX, 
    113                                                 TK_RegularExpression, TK_while, TK_LPAREN, TK_true, 
     110                                new int[] { TK_var, TK_IDENTIFIER, TK_ASSIGN, 
     111                                                TK_RegularExpression, TK_VirtualSemicolon, TK_while, TK_LPAREN, TK_true, 
    114112                                                TK_RPAREN, TK_IDENTIFIER, TK_LPAREN, TK_RPAREN, TK_SEMI }); 
    115113        } 
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/BasicParserTest.java

    r82cecb8 rb32f7a4  
    11package org.axdt.as3.imp.parser; 
     2 
     3import java.util.ArrayList; 
    24 
    35import junit.framework.TestCase; 
     
    1012import org.axdt.as3.imp.parser.Ast.FunctionExpression; 
    1113import org.axdt.as3.imp.parser.Ast.IDirective; 
    12 import org.axdt.as3.imp.parser.Ast.ImportDirectiveList; 
     14import org.axdt.as3.imp.parser.Ast.ImportDirectives; 
    1315import org.axdt.as3.imp.parser.Ast.InterfaceDefinition; 
    1416import org.axdt.as3.imp.parser.Ast.Name; 
     
    1921 
    2022public class BasicParserTest extends TestCase { 
     23        private AS3Parser parser; 
    2124        private Program parse(String content) { 
    22                 return ParseUtil.parse(content); 
    23         } 
    24  
     25                parser = ParseUtil.parser(content); 
     26                return ParseUtil.parse(parser,0); 
     27        } 
     28        private <T extends IDirective> T assertFirstDirective(String string, Class<T> clazz) { 
     29                parser = ParseUtil.parser(string); 
     30                Program result = ParseUtil.parse(parser,0); 
     31                return assertFirstDirective(result, clazz); 
     32        } 
     33        @SuppressWarnings("unchecked") 
     34        private <T extends IDirective> T assertFirstDirective(Program prog, Class<T> clazz) { 
     35                IDirective directive = null; 
     36                if (prog != null) { 
     37                        directive = prog.getDirectives().getDirectiveAt(0); 
     38                } else { 
     39                        // TODO gather some info 
     40                        ArrayList tokens = parser.getIPrsStream().getTokens(); 
     41                        assertNotNull("parser error "+ tokens.toString(),prog); 
     42                } 
     43                assertNotNull(directive); 
     44                assertEquals(clazz, directive.getClass()); 
     45                return (T) directive; 
     46        } 
    2547        public void testPackage() throws Exception { 
    2648                Program prog; 
     
    5476                prog = parse("package P{} f();"); 
    5577                assertEquals(1, prog.getPackages().size()); 
    56                 assertEquals(1, prog.getDirectives().size()); 
     78                assertFirstDirective(prog,ExpressionStatement.class); 
    5779 
    5880                // bom works just as expected 
     
    6789                prog = parse("package P{} package Q{} function f(){}"); 
    6890                assertEquals(2, prog.getPackages().size()); 
    69                 assertEquals(1, prog.getDirectives().size()); 
     91                assertFirstDirective(prog,FunctionDefinition.class); 
    7092                 
    7193                System.out.print("expected"); 
     
    7597 
    7698        public void testNamespace() throws Exception { 
    77                 Program prog; 
    7899                NamespaceDefinition dir; 
    79100                 
    80                 prog = parse("namespace NS1"); 
    81                 assertEquals(true, prog.getDirectives().getDirectiveAt(0) instanceof NamespaceDefinition); 
    82                 dir = (NamespaceDefinition) prog.getDirectives().getDirectiveAt(0); 
     101                dir = assertFirstDirective("namespace NS1",NamespaceDefinition.class); 
    83102                assertEquals("NS1", dir.getName().toString()); 
    84103                 
    85                 prog = parse("namespace NS2 = NS1"); 
    86                 assertEquals(true, prog.getDirectives().getDirectiveAt(0) instanceof NamespaceDefinition); 
    87                 dir = (NamespaceDefinition) prog.getDirectives().getDirectiveAt(0); 
     104                dir = assertFirstDirective("namespace NS2 = NS1",NamespaceDefinition.class); 
    88105                assertEquals("NS2", dir.getName().toString()); 
    89106                assertEquals("NS1", dir.getAssignment().toString()); 
    90107                 
    91                 prog = parse("namespace NS3 = \"http://www.macromedia.com/flash/2005\""); 
    92                 assertEquals(true, prog.getDirectives().getDirectiveAt(0) instanceof NamespaceDefinition); 
    93                 dir = (NamespaceDefinition) prog.getDirectives().getDirectiveAt(0); 
     108                dir = assertFirstDirective("namespace NS3 = \"http://www.macromedia.com/flash/2005\"",NamespaceDefinition.class); 
    94109                assertEquals("NS3", dir.getName().toString()); 
    95110                assertEquals(StringLiteral.class, dir.getAssignment().getClass()); 
     
    98113 
    99114        public void testImport() throws Exception { 
    100                 Program prog; ImportDirectiveList list; 
    101                 prog = parse("import A;"); 
    102                 assertEquals(ImportDirectiveList.class, prog.getDirectives().getDirectiveAt(0).getClass()); 
    103                 prog = parse("import A; import a.b.C; import abc.*;"); 
    104                 list = (ImportDirectiveList) prog.getDirectives().getDirectiveAt(0); 
     115                ImportDirectives list; 
     116                list = assertFirstDirective("import A;",ImportDirectives.class); 
     117                assertEquals(1, list.size()); 
     118                list = assertFirstDirective("import A; import a.b.C; import abc.*;",ImportDirectives.class); 
    105119                assertEquals(3, list.size()); 
    106120                assertEquals("A", list.getImportDirectiveAt(0).getName().toString()); 
     
    112126 
    113127        public void testInterface() throws Exception { 
    114                 Program prog; InterfaceDefinition type; 
    115                  
    116                 prog = parse("interface A {}"); 
    117                 assertEquals(InterfaceDefinition.class, prog.getDirectives().getDirectiveAt(0).getClass()); 
    118                 type = (InterfaceDefinition) prog.getDirectives().getDirectiveAt(0); 
     128                InterfaceDefinition type; 
     129                 
     130                type = assertFirstDirective("interface A {}",InterfaceDefinition.class); 
    119131                assertEquals(Name.class, type.getName().getClass()); 
    120132                assertEquals(null, type.getBody().getDirectives()); 
    121133                 
    122                 prog = parse("interface a.b.C {}"); 
    123                 assertEquals(InterfaceDefinition.class, prog.getDirectives().getDirectiveAt(0).getClass()); 
    124                 type = (InterfaceDefinition) prog.getDirectives().getDirectiveAt(0); 
     134                type = assertFirstDirective("interface a.b.C {}",InterfaceDefinition.class); 
    125135                assertEquals(Name.class, type.getName().getClass()); 
    126136                assertEquals(null, type.getBody().getDirectives()); 
    127137                 
    128                 prog = parse("interface A { function f():A;function g():B;}"); 
    129                 assertEquals(InterfaceDefinition.class, prog.getDirectives().getDirectiveAt(0).getClass()); 
    130                 type = (InterfaceDefinition) prog.getDirectives().getDirectiveAt(0); 
     138                type = assertFirstDirective("interface A { function f():A;function g():B;}",InterfaceDefinition.class); 
    131139                assertEquals(2, type.getBody().getDirectives().size()); 
    132140                 
    133                 prog = parse("internal interface A {} public interface B{}"); 
    134                 assertEquals(AnnotatedDirective.class, prog.getDirectives().getDirectiveAt(0).getClass()); 
    135                 assertEquals(AnnotatedDirective.class, prog.getDirectives().getDirectiveAt(1).getClass()); 
     141                assertFirstDirective("internal interface A {}",AnnotatedDirective.class); 
     142                assertFirstDirective("public interface A {}",AnnotatedDirective.class); 
    136143        } 
    137144 
    138145        public void testVariable() throws Exception { 
    139                 Program prog; IDirective directive;  
    140                  
    141                 prog = parse("var a;"); 
    142                 directive = prog.getDirectives().getDirectiveAt(0); 
    143                 assertEquals(VariableDefinition.class, directive.getClass()); 
    144                  
    145                 assertEquals(AnnotatedDirective.class, parse("static var a;").getDirectives().getDirectiveAt(0).getClass()); 
    146                 assertEquals(AnnotatedDirective.class, parse("prototype var a;").getDirectives().getDirectiveAt(0).getClass()); 
    147                 assertEquals(AnnotatedDirective.class, parse("private var a;").getDirectives().getDirectiveAt(0).getClass()); 
    148                 assertEquals(AnnotatedDirective.class, parse("public var a;").getDirectives().getDirectiveAt(0).getClass()); 
    149                 assertEquals(AnnotatedDirective.class, parse("protected var a;").getDirectives().getDirectiveAt(0).getClass()); 
    150                 assertEquals(AnnotatedDirective.class, parse("internal var a;").getDirectives().getDirectiveAt(0).getClass()); 
     146                assertFirstDirective("var a;",VariableDefinition.class); 
     147                assertFirstDirective("static var a;",AnnotatedDirective.class); 
     148                assertFirstDirective("prototype var a;",AnnotatedDirective.class); 
     149                assertFirstDirective("private var a;",AnnotatedDirective.class); 
     150                assertFirstDirective("public var a;",AnnotatedDirective.class); 
     151                assertFirstDirective("protected var a;",AnnotatedDirective.class); 
     152                assertFirstDirective("internal var a;",AnnotatedDirective.class); 
    151153        } 
    152154         
    153155        public void testFunction() throws Exception { 
    154                 Program prog; IDirective directive; FunctionDefinition def; 
    155                 prog = parse("function f():void{}"); 
    156                 directive = prog.getDirectives().getDirectiveAt(0); 
    157                 assertEquals(FunctionDefinition.class, directive.getClass()); 
    158  
    159                 prog = parse("function f(b:B){a = b;a.c();}"); 
    160                 directive = prog.getDirectives().getDirectiveAt(0); 
    161                 def = (FunctionDefinition) directive; 
     156                IDirective directive; FunctionDefinition def; 
     157                def = assertFirstDirective("function f():void{}",FunctionDefinition.class); 
     158 
     159                def = assertFirstDirective("function f(b:B){a = b;a.c();}",FunctionDefinition.class); 
    162160                assertEquals("f", def.getName().toString()); 
    163161                assertEquals(2, def.getBlock().getDirectives().size()); 
     
    165163                assertEquals(null, common.getResultType()); 
    166164 
    167                 assertEquals(FunctionDefinition.class, parse("function f(){}").getDirectives().getDirectiveAt(0).getClass()); 
    168                 assertEquals(FunctionDefinition.class, parse("function f(...){}").getDirectives().getDirectiveAt(0).getClass()); 
    169                 assertEquals(FunctionDefinition.class, parse("function f(...b){}").getDirectives().getDirectiveAt(0).getClass()); 
    170                 assertEquals(FunctionDefinition.class, parse("function f(...b:B){}").getDirectives().getDirectiveAt(0).getClass()); 
    171                 assertEquals(FunctionDefinition.class, parse("function f(a:A,...b:B){}").getDirectives().getDirectiveAt(0).getClass()); 
    172                  
    173                 assertEquals(AnnotatedDirective.class, parse("static function a(){}").getDirectives().getDirectiveAt(0).getClass()); 
    174                 assertEquals(AnnotatedDirective.class, parse("override function a(){}").getDirectives().getDirectiveAt(0).getClass()); 
    175                 assertEquals(AnnotatedDirective.class, parse("final function a(){}").getDirectives().getDirectiveAt(0).getClass()); 
    176                 assertEquals(AnnotatedDirective.class, parse("private function a(){}").getDirectives().getDirectiveAt(0).getClass()); 
    177                 assertEquals(AnnotatedDirective.class, parse("public function a(){}").getDirectives().getDirectiveAt(0).getClass()); 
    178                 assertEquals(AnnotatedDirective.class, parse("protected function a(){}").getDirectives().getDirectiveAt(0).getClass()); 
    179                 assertEquals(AnnotatedDirective.class, parse("internal function a(){}").getDirectives().getDirectiveAt(0).getClass()); 
    180                 assertEquals(AnnotatedDirective.class, parse("prototype function a(){}").getDirectives().getDirectiveAt(0).getClass()); 
    181                 assertEquals(AnnotatedDirective.class, parse("native function a(){}").getDirectives().getDirectiveAt(0).getClass()); 
    182                  
    183                 prog = parse("function(b:B){a = b;};"); 
    184                 directive = prog.getDirectives().getDirectiveAt(0); 
    185                 assertEquals(ExpressionStatement.class, directive.getClass()); 
     165                def = assertFirstDirective("function f(){}",FunctionDefinition.class); 
     166                def = assertFirstDirective("function f(...){}",FunctionDefinition.class); 
     167                def = assertFirstDirective("function f(...b){}",FunctionDefinition.class); 
     168                def = assertFirstDirective("function f(...b:B){}",FunctionDefinition.class); 
     169                def = assertFirstDirective("function f(a:A,...b:B){}",FunctionDefinition.class); 
     170                def = assertFirstDirective("function get f(){}",FunctionDefinition.class); 
     171                def = assertFirstDirective("function get f(i){}",FunctionDefinition.class); 
     172                def = assertFirstDirective("function get f(a:A,b:B){}",FunctionDefinition.class); 
     173                // TODO fix parameter declaration 
     174                def = assertFirstDirective("function set(){}",FunctionDefinition.class); 
     175                def = assertFirstDirective("function get(a,b){}",FunctionDefinition.class); 
     176                def = assertFirstDirective("function get(a:A,b){}",FunctionDefinition.class); 
     177                def = assertFirstDirective("function get(a:A,b:*){}",FunctionDefinition.class); 
     178                def = assertFirstDirective("function get(a:A,b:*):C{}",FunctionDefinition.class); 
     179                def = assertFirstDirective("function get(){}",FunctionDefinition.class); 
     180                def = assertFirstDirective("function get(a:A){}",FunctionDefinition.class); 
     181                def = assertFirstDirective("function get(a:A,b:B,c:C):D {}",FunctionDefinition.class); 
     182                 
     183                assertFirstDirective("static function a(){}", AnnotatedDirective.class); 
     184                assertFirstDirective("override function a(){}", AnnotatedDirective.class); 
     185                assertFirstDirective("final function a(){}", AnnotatedDirective.class); 
     186                assertFirstDirective("private function a(){}", AnnotatedDirective.class); 
     187                assertFirstDirective("public function a(){}", AnnotatedDirective.class); 
     188                assertFirstDirective("protected function a(){}", AnnotatedDirective.class); 
     189                assertFirstDirective("internal function a(){}", AnnotatedDirective.class); 
     190                assertFirstDirective("prototype function a(){}", AnnotatedDirective.class); 
     191                assertFirstDirective("native function a(){}", AnnotatedDirective.class); 
     192 
     193                directive = assertFirstDirective("function(b:B){a = b;};", ExpressionStatement.class); 
    186194                assertEquals(FunctionExpression.class, ((ExpressionStatement)directive).getExpression().getClass()); 
    187195        } 
    188196 
    189197        public void testClass() throws Exception { 
    190                 Program prog; ClassDefinition def; 
    191                 prog = parse("class T{}"); 
    192                 assertEquals(ClassDefinition.class, prog.getDirectives().getDirectiveAt(0).getClass()); 
    193                 prog = parse("class T{function T(){}function S(){}}"); 
    194                 def = (ClassDefinition) prog.getDirectives().getDirectiveAt(0); 
     198                ClassDefinition def; 
     199                assertFirstDirective("class T{}", ClassDefinition.class); 
     200                def = assertFirstDirective("class T{function T(){}function S(){}}", ClassDefinition.class); 
    195201                assertEquals("T", def.getName().toString()); 
    196202                assertEquals(2, def.getBody().getDirectives().size()); 
     
    198204                assertEquals(FunctionDefinition.class, def.getBody().getDirectives().getDirectiveAt(1).getClass()); 
    199205                 
    200                 prog = parse("internal class A {} public class B{} final class C{} dynamic class D{}"); 
    201                 assertEquals(AnnotatedDirective.class, prog.getDirectives().getDirectiveAt(0).getClass()); 
    202                 assertEquals(AnnotatedDirective.class, prog.getDirectives().getDirectiveAt(1).getClass()); 
    203                 assertEquals(AnnotatedDirective.class, prog.getDirectives().getDirectiveAt(2).getClass()); 
    204                 assertEquals(AnnotatedDirective.class, prog.getDirectives().getDirectiveAt(3).getClass()); 
     206                assertFirstDirective("internal class A {}", AnnotatedDirective.class); 
     207                assertFirstDirective("public class A {}", AnnotatedDirective.class); 
     208                assertFirstDirective("dynamic class A {}", AnnotatedDirective.class); 
     209                assertFirstDirective("final class A {}", AnnotatedDirective.class); 
    205210        } 
    206211 
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/ExpressionTest.java

    r82cecb8 rb32f7a4  
    8787                assertExpression(parse("get"),Ident.class); 
    8888                assertExpression(parse("set"),Ident.class); 
    89                 //assertExpression(parse("namespace"),Ident.class); 
     89                assertExpression(parse("namespace"),Ident.class); 
    9090                assertExpression(parse("include"),Ident.class); 
    9191                assertExpression(parse("dynamic"),Ident.class); 
     
    166166                assertExpression(parse("a>>>b>>>c"),ShiftExpression.class); 
    167167                assertExpression(parse("a<b"),RelationalExpression.class); 
    168                 assertExpression(parse("a<b"),RelationalExpression.class); 
    169168                assertExpression(parse("a>b"),RelationalExpression.class); 
    170169                assertExpression(parse("a<=b"),RelationalExpression.class); 
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/ParseUtil.java

    r5eb830a rb32f7a4  
    1313                AS3Parser parser = new AS3Parser(); 
    1414                parser.reset(lexer.getILexStream()); 
    15                 lexer.lexer(null, parser.getIPrsStream()); 
     15                lexer.lexer(null, parser); 
    1616                return parser.getIPrsStream(); 
    1717        } 
    1818        public static Program parse(String content) { 
    19                 return parse(content, -1, false); 
     19                return parse(content, -1); 
    2020        } 
    21         public static Program parse(String content, int repair, boolean virtualSemi) { 
     21        public static Program parse(String content, int repair) { 
     22                AS3Parser parser = parser(content); 
     23                return parse(parser,repair); 
     24        } 
     25        public static Program parse(AS3Parser parser, int repair) { 
     26                Object object = parser.parser(repair); 
     27                if (object instanceof Program) 
     28                        return (Program) object; 
     29                return null; 
     30        } 
     31        public static AS3Parser parser(String content) { 
    2232                char[] charArray = content.toCharArray(); 
    2333                AS3Lexer lexer = new AS3Lexer(); 
     
    2535                AS3Parser parser = new AS3Parser(); 
    2636                parser.reset(lexer.getILexStream()); 
    27                 lexer.lexer(null, parser, virtualSemi); 
    28                 Object object = parser.parser(repair); 
    29                 if (object instanceof Program) 
    30                         return (Program) object; 
    31                 return null; 
     37                lexer.lexer(null, parser); 
     38                return parser; 
    3239        } 
    3340} 
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/RegexContextTest.java

    r5eb830a rb32f7a4  
    11package org.axdt.as3.imp.parser; 
    22 
     3 
     4import junit.framework.TestCase; 
    35 
    46import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 
     
    1012import org.axdt.as3.imp.parser.Ast.VariableInitialisation; 
    1113 
    12 import junit.framework.TestCase; 
    13  
    1414public class RegexContextTest extends TestCase { 
    1515        private Program parse(String content) { 
    16                 return ParseUtil.parse(content,0,false); 
     16                return ParseUtil.parse(content,0); 
    1717        } 
    1818 
     
    3535        } 
    3636        String longTest = "function f():int{\n" + 
    37         "\tvar r:Regex=/AXDT/gi;\n" + 
     37        "\tvar r:Regex=/AXDT/gi; \n" + 
    3838        "\tif(0<='AXDT'.search(r))\n" + 
    3939        "\t\treturn 1337;\n" + 
     
    4141        "}"; 
    4242        String longTest2 = "function f():int{\n" + 
    43         "\tvar r:Regex=/AXDT/gi;\n" + 
    44         "\tif(0<='AXDT'.search(r)){\n" + 
     43        "\tvar r:String='test';\n" + 
     44        "\tvar xml:XML=<xml/>; \n" + 
     45        "\tif(xml.toString()!=null){\n" + 
    4546        "\t\treturn 1337;\n" + 
    4647        "\t}return 0;\n" + 
    4748        "}"; 
    4849        public void testWithVSemi() throws Exception { 
    49                 // i finally (after 3 h concentrated work) got to the cause of 
    5050                // http://axdt.org/ticket/151 "strange error with regex and whitespace" 
    51                 // turns out it is a virtual semicolon merged in there for no good reason 
    52                 // because it is not easy to determine from the context  
    53                 // whether an insertion is acceptable  
    54                 // we just skip when last token is RPAREN ")"  
    55                 assertNotNull(ParseUtil.parse(longTest,0,true)); 
    56                 assertNotNull(ParseUtil.parse(longTest2,0,true)); 
     51                // fixed whole semicolon handling 
     52                assertNotNull(parse(longTest)); 
     53                assertNotNull(parse(longTest2)); 
     54                // should now even work without the semicolons 
     55                assertNotNull(parse(longTest.replace(";",""))); 
     56                assertNotNull(parse(longTest2.replace(";",""))); 
    5757        } 
    5858} 
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/TutorialParserTest.java

    re9006de rb32f7a4  
    11package org.axdt.as3.imp.parser; 
     2 
     3import junit.framework.TestCase; 
    24 
    35import org.axdt.as3.imp.parser.Ast.ExpressionStatement; 
    46import org.axdt.as3.imp.parser.Ast.IDirective; 
    57import org.axdt.as3.imp.parser.Ast.Program; 
    6  
    7 import junit.framework.TestCase; 
    88 
    99public class TutorialParserTest extends TestCase { 
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/VirtualSemiTest.java

    r82cecb8 rb32f7a4  
    77public class VirtualSemiTest extends TestCase { 
    88 
    9         public static Program parse(String content, boolean insertVirtualSemi) { 
    10                 return ParseUtil.parse(content, 0, insertVirtualSemi); 
     9        public static Program parse(String content) { 
     10                return ParseUtil.parse(content, 0); 
    1111        } 
    12         public void testVirtualSemi() throws Exception { 
    13                 assertNotNull(parse("{var i = 0;var j = 1;}", false)); 
    14                 // without virtual semi 
    15                 System.out.print("expected"); 
    16                 assertNull(parse("{var i = 0\nvar j = 1;}", false)); 
    17                 // with insertion  
    18                 assertNotNull(parse("{var i = 0;\nvar j = 1;}", true)); 
    19                 assertNotNull(parse("{var i = 0\n;var j = 1;}", true)); 
    20                 assertNotNull(parse("{var i = 0\nvar j = 1;}", true)); 
     12        public void testLineBreakVirtualSemi() throws Exception { 
     13                // TODO check that the parser should not insert v semi 
     14                assertNotNull(parse("{var i = 0;\nvar j = 1;}")); 
     15                // TODO dont insert if there is a semi  
     16                assertNotNull(parse("{var i = 0\n;var j = 1;}")); 
     17                assertNotNull(parse("{var i = 0\nvar j = 1;}")); 
     18        } 
     19        public void testGrammarVirtualSemi() throws Exception { 
     20                // abbrev semi is inserted before RCURLY or EOF 
     21                assertNotNull(parse("var j = 1")); 
     22                assertNotNull(parse("var j = 1;")); 
     23                assertNotNull(parse("{var i = 0;var j = 1}")); 
    2124        } 
    2225} 
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/xml/BasicXmlTest.java

    r01bd3b5 rb32f7a4  
    2727                System.out.print("expected"); 
    2828                assertNull(parse("<= 6;")); 
     29                System.out.print("expected"); 
     30                assertNull(parse("<x")); 
    2931                assertNotNull(parse("<xml></lmx>")); 
    3032                 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Lexer.gi

    r69d1ca8 rb32f7a4  
    99%options single-productions 
    1010%options package=org.axdt.as3.imp.parser 
    11 %options template=LexerTemplateF.gi 
     11%options template=LexerTemplate.ggg 
    1212%options filter=AS3KWLexer.gi 
    1313 
    1414%Notice 
    15         /./* 
    16            * (c) Martin Schnabel - mb0@mb0.org 
    17            */ 
    18         ./ 
     15    /./* 
     16       * (c) Martin Schnabel - mb0@mb0.org 
     17       */ 
     18    ./ 
    1919%END 
    2020 
    2121%Globals 
    2222    /. 
    23     import java.util.ArrayList; 
    2423    import org.eclipse.imp.parser.ILexer; 
    25     import org.axdt.as3.imp.parser.xml.*; 
    26     import org.axdt.as3.imp.parser.regex.*; 
    2724    ./ 
    2825%End 
     
    5451    STRICT_NOT_EQUAL 
    5552    DIV 
    56     DIV_RX 
    5753    DIV_ASSIGN 
    5854    PLUS 
     
    171167 
    172168%Start 
    173     NextInputElement     
     169    NextInputElement     
    174170%End 
    175171 
     
    212208    WhiteSpace ::= 
    213209       WhiteSpaceCharacter 
    214     |  LineTerminator 
    215210    |  WhiteSpace WhiteSpaceCharacter 
    216     |  WhiteSpace LineTerminator 
     211 
     212    NewLines ::= 
     213       LineTerminator 
     214    |  NewLines LineTerminator 
    217215 
    218216    NextInputElement ::= ByteOrderMark 
    219217        /.$BeginAction 
    220                 makeBom(); 
     218        make.bom(); 
    221219          $EndAction./ 
    222220    NextInputElement ::= WhiteSpace 
    223221        /.$BeginAction 
    224                 skipToken(); 
     222        make.whiteSpace(); 
     223          $EndAction./ 
     224    NextInputElement ::= NewLines 
     225        /.$BeginAction 
     226        make.newLines(); 
    225227          $EndAction./ 
    226228    NextInputElement ::= IdentifierOrKeyword 
    227229        /.$BeginAction 
    228                 checkForKeyWord(); 
     230        make.keyWord(); 
    229231          $EndAction./ 
    230232    NextInputElement ::= Punctuator 
    231233    NextInputElement ::= NumericLiteral 
    232234        /.$BeginAction 
    233                 makeToken($_Number); 
     235        make.token($_Number); 
    234236          $EndAction./ 
    235237    NextInputElement ::= StringLiteral 
    236238        /.$BeginAction 
    237                 makeToken($_String); 
     239        make.token($_String); 
    238240          $EndAction./ 
    239241    NextInputElement ::= LineComment 
    240242        /.$BeginAction 
    241                 makeComment($_SlComment); 
     243        make.comment($_SlComment); 
    242244          $EndAction./ 
    243245    NextInputElement ::= BlockComment 
    244246        /.$BeginAction 
    245                 makeComment($_MlComment); 
     247        make.comment($_MlComment); 
    246248          $EndAction./ 
    247249 
     
    393395    Punctuator ::= '?' 
    394396        /.$BeginJava 
    395                 makeToken($_QUESTION); 
     397        make.token($_QUESTION); 
    396398          $EndJava./ 
    397399    Punctuator ::= '(' 
    398400        /.$BeginJava 
    399                 makeToken($_LPAREN); 
     401        make.token($_LPAREN); 
    400402          $EndJava./ 
    401403    Punctuator ::= ')' 
    402404        /.$BeginJava 
    403                 makeToken($_RPAREN); 
     405        make.token($_RPAREN); 
    404406          $EndJava./ 
    405407    Punctuator ::= '[' 
    406408        /.$BeginJava 
    407                 makeToken($_LBRACK); 
     409        make.token($_LBRACK); 
    408410          $EndJava./ 
    409411    Punctuator ::= ']' 
    410412        /.$BeginJava 
    411                 makeToken($_RBRACK); 
     413        make.token($_RBRACK); 
    412414          $EndJava./ 
    413415    Punctuator ::= '{' 
    414416        /.$BeginJava 
    415                 makeToken($_LCURLY); 
     417        make.token($_LCURLY); 
    416418          $EndJava./ 
    417419    Punctuator ::= '}' 
    418420        /.$BeginJava 
    419                 makeToken($_RCURLY); 
     421        make.token($_RCURLY); 
    420422          $EndJava./ 
    421423    Punctuator ::= ':' ':' 
    422424        /.$BeginJava 
    423                 makeToken($_DBL_COLON); 
     425        make.token($_DBL_COLON); 
    424426          $EndJava./ 
    425427    Punctuator ::= ':' 
    426428        /.$BeginJava 
    427                 makeToken($_COLON); 
     429        make.token($_COLON); 
    428430          $EndJava./ 
    429431    Punctuator ::= ',' 
    430432        /.$BeginJava 
    431                 makeToken($_COMMA); 
     433        make.token($_COMMA); 
    432434          $EndJava./ 
    433435    Punctuator ::= '=' 
    434436        /.$BeginJava 
    435                 makeToken($_ASSIGN); 
     437        make.token($_ASSIGN); 
    436438          $EndJava./ 
    437439    Punctuator ::= '=' '=' 
    438440        /.$BeginJava 
    439                 makeToken($_EQUAL); 
     441        make.token($_EQUAL); 
    440442          $EndJava./ 
    441443    Punctuator ::= '=' '=' '=' 
    442444        /.$BeginJava 
    443                 makeToken($_STRICT_EQUAL); 
     445        make.token($_STRICT_EQUAL); 
    444446          $EndJava./ 
    445447    Punctuator ::= '!' 
    446448        /.$BeginJava 
    447                 makeToken($_LNOT); 
     449        make.token($_LNOT); 
    448450          $EndJava./ 
    449451    Punctuator ::= '~' 
    450452        /.$BeginJava 
    451                 makeToken($_BNOT); 
     453        make.token($_BNOT); 
    452454          $EndJava./ 
    453455    Punctuator ::= '!' '=' 
    454456        /.$BeginJava 
    455                 makeToken($_NOT_EQUAL); 
     457        make.token($_NOT_EQUAL); 
    456458          $EndJava./ 
    457459    Punctuator ::= '!' '=' '=' 
    458460        /.$BeginJava 
    459                 makeToken($_STRICT_NOT_EQUAL); 
     461        make.token($_STRICT_NOT_EQUAL); 
    460462          $EndJava./ 
    461463    Punctuator ::= '/' 
    462464        /.$BeginJava 
    463                 makeToken($_DIV); 
     465        make.token($_DIV); 
    464466          $EndJava./ 
    465467    Punctuator ::= '/' '=' 
    466468        /.$BeginJava 
    467                 makeToken($_DIV_ASSIGN); 
     469        make.token($_DIV_ASSIGN); 
    468470          $EndJava./ 
    469471    Punctuator ::= '+' 
    470472        /.$BeginJava 
    471                 makeToken($_PLUS); 
     473        make.token($_PLUS); 
    472474          $EndJava./ 
    473475    Punctuator ::= '+' '=' 
    474476        /.$BeginJava 
    475                 makeToken($_PLUS_ASSIGN); 
     477        make.token($_PLUS_ASSIGN); 
    476478          $EndJava./ 
    477479    Punctuator ::= '+' '+' 
    478480        /.$BeginJava 
    479                 makeToken($_INC); 
     481        make.token($_INC); 
    480482          $EndJava./ 
    481483    Punctuator ::= '-' 
    482484        /.$BeginJava 
    483                 makeToken($_MINUS); 
     485        make.token($_MINUS); 
    484486          $EndJava./ 
    485487    Punctuator ::= '-' '=' 
    486488        /.$BeginJava 
    487                 makeToken($_MINUS_ASSIGN); 
     489        make.token($_MINUS_ASSIGN); 
    488490          $EndJava./ 
    489491    Punctuator ::= '-' '-' 
    490492        /.$BeginJava 
    491                 makeToken($_DEC); 
     493        make.token($_DEC); 
    492494          $EndJava./ 
    493495    Punctuator ::= '*' 
    494496        /.$BeginJava 
    495                 makeToken($_STAR); 
     497        make.token($_STAR); 
    496498          $EndJava./ 
    497499    Punctuator ::= '*' '=' 
    498500        /.$BeginJava 
    499                 makeToken($_STAR_ASSIGN); 
     501        make.token($_STAR_ASSIGN); 
    500502          $EndJava./ 
    501503    Punctuator ::= '%' 
    502504        /.$BeginJava 
    503                 makeToken($_MOD); 
     505        make.token($_MOD); 
    504506          $EndJava./ 
    505507    Punctuator ::= '%' '=' 
    506508        /.$BeginJava 
    507                 makeToken($_MOD_ASSIGN); 
     509        make.token($_MOD_ASSIGN); 
    508510          $EndJava./ 
    509511    Punctuator ::= '>' '>' 
    510512        /.$BeginJava 
    511                 makeToken($_SR); 
     513        make.token($_SR); 
    512514          $EndJava./ 
    513515    Punctuator ::= '>' '>' '=' 
    514516        /.$BeginJava 
    515                 makeToken($_SR_ASSIGN); 
     517        make.token($_SR_ASSIGN); 
    516518          $EndJava./ 
    517519    Punctuator ::= '>' '>' '>' 
    518520        /.$BeginJava 
    519                 makeToken($_BSR); 
     521        make.token($_BSR); 
    520522          $EndJava./ 
    521523    Punctuator ::= '>' '>' '>' '=' 
    522524        /.$BeginJava 
    523                 makeToken($_BSR_ASSIGN); 
     525        make.token($_BSR_ASSIGN); 
    524526          $EndJava./ 
    525527    Punctuator ::= '>' '=' 
    526528        /.$BeginJava 
    527                 makeToken($_GE); 
     529        make.token($_GE); 
    528530          $EndJava./ 
    529531    Punctuator ::= '>' 
    530532        /.$BeginJava 
    531                 makeToken($_GT); 
     533        make.token($_GT); 
    532534          $EndJava./ 
    533535    Punctuator ::= '<' '<' 
    534536        /.$BeginJava 
    535                 makeToken($_SL); 
     537        make.token($_SL); 
    536538          $EndJava./ 
    537539    Punctuator ::= '<' '<' '=' 
    538540        /.$BeginJava 
    539                 makeToken($_SL_ASSIGN); 
     541        make.token($_SL_ASSIGN); 
    540542          $EndJava./ 
    541543    Punctuator ::= '<' '=' 
    542544        /.$BeginJava 
    543                 makeToken($_LE); 
     545        make.token($_LE); 
    544546          $EndJava./ 
    545547    Punctuator ::= '<' 
    546548        /.$BeginJava 
    547                 makeToken($_LT); 
     549        make.token($_LT); 
    548550          $EndJava./ 
    549551    Punctuator ::= '^' 
    550552        /.$BeginJava 
    551                 makeToken($_BXOR); 
     553        make.token($_BXOR); 
    552554          $EndJava./ 
    553555    Punctuator ::= '^' '=' 
    554556        /.$BeginJava 
    555                 makeToken($_BXOR_ASSIGN); 
     557        make.token($_BXOR_ASSIGN); 
    556558          $EndJava./ 
    557559    Punctuator ::= '^' '^' '=' 
    558560        /.$BeginJava 
    559                 makeToken($_LXOR_ASSIGN); 
     561        make.token($_LXOR_ASSIGN); 
    560562          $EndJava./ 
    561563    Punctuator ::= '|' 
    562564        /.$BeginJava 
    563                 makeToken($_BOR); 
     565        make.token($_BOR); 
    564566          $EndJava./ 
    565567    Punctuator ::= '|' '=' 
    566568        /.$BeginJava 
    567                 makeToken($_BOR_ASSIGN); 
     569        make.token($_BOR_ASSIGN); 
    568570          $EndJava./ 
    569571    Punctuator ::= '|' '|' 
    570572        /.$BeginJava 
    571                 makeToken($_LOR); 
     573        make.token($_LOR); 
    572574          $EndJava./ 
    573575    Punctuator ::= '|' '|' '=' 
    574576        /.$BeginJava 
    575                 makeToken($_LOR_ASSIGN); 
     577        make.token($_LOR_ASSIGN); 
    576578          $EndJava./ 
    577579    Punctuator ::= '&' 
    578580        /.$BeginJava 
    579                 makeToken($_BAND); 
     581        make.token($_BAND); 
    580582          $EndJava./ 
    581583    Punctuator ::= '&' '=' 
    582584        /.$BeginJava 
    583                 makeToken($_BAND_ASSIGN); 
     585        make.token($_BAND_ASSIGN); 
    584586          $EndJava./ 
    585587    Punctuator ::= '&' '&' 
    586588        /.$BeginJava 
    587                 makeToken($_LAND); 
     589        make.token($_LAND); 
    588590          $EndJava./ 
    589591    Punctuator ::= '&' '&' '=' 
    590592        /.$BeginJava 
    591                 makeToken($_LAND_ASSIGN); 
     593        make.token($_LAND_ASSIGN); 
    592594          $EndJava./ 
    593595    Punctuator ::= '@' 
    594596        /.$BeginJava 
    595                 makeToken($_E4X_ATTRI); 
     597        make.token($_E4X_ATTRI); 
    596598          $EndJava./ 
    597599    Punctuator ::= ';' 
    598600        /.$BeginJava 
    599                 makeToken($_SEMI); 
     601        make.token($_SEMI); 
    600602          $EndJava./ 
    601603    Punctuator ::= '.' 
    602604        /.$BeginJava 
    603                 makeToken($_DOT); 
     605        make.token($_DOT); 
    604606          $EndJava./ 
    605607    Punctuator ::= '.' '.' 
    606608        /.$BeginJava 
    607                 makeToken($_E4X_DESC); 
     609        make.token($_E4X_DESC); 
    608610          $EndJava./ 
    609611    Punctuator ::= '.' '.' '.' 
    610612        /.$BeginJava 
    611                 makeToken($_REST); 
     613        make.token($_REST); 
    612614          $EndJava./ 
    613615%End 
     
    615617%Headers 
    616618    /. 
    617         XmlParser xmlParser = null; 
    618         XmlParser getXmlParser() { 
    619                 if (xmlParser == null) { 
    620                         xmlParser = new XmlParser(); 
    621                 } 
    622                 xmlParser.reset(lexStream); 
    623                 return xmlParser; 
    624         } 
    625         RegexParser regexParser = null; 
    626         RegexParser getRegexParser() { 
    627                 if (regexParser == null) { 
    628                         regexParser = new RegexParser(); 
    629                 } 
    630                 regexParser.reset(lexStream); 
    631                 return regexParser; 
    632         } 
    633         IToken getLastToken() { 
    634                 IPrsStream prsStream = lexStream.getIPrsStream(); 
    635                 ArrayList<?> tokens = prsStream.getTokens(); 
    636                 if (tokens.size()>0) { 
    637                         return (IToken) tokens.get(tokens.size()-1); 
    638                 } 
    639                 return null; 
    640         } 
    641         public boolean canBeRegex(IToken last) { 
    642                 if (last != null) { 
    643                         switch (last.getKind()) { 
    644                         case AS3Parsersym.TK_Number: 
    645                         case AS3Parsersym.TK_IDENTIFIER: 
    646                         case AS3Parsersym.TK_RBRACK: 
    647                         case AS3Parsersym.TK_RPAREN: 
    648                                 return false; 
    649                         } 
    650                 } 
    651                 return true; 
    652         } 
    653         boolean insertVirtualSemicolon = false; 
    654         DeterministicParser probeParser = null; 
    655         int ERROR_ACTION; 
    656         public void makeToken(int startLoc, int endLoc, int kind) { 
    657             if (insertVirtualSemicolon && probeParser != null) { 
    658                 // if there is an error if we probe the current token 
    659                 if (ERROR_ACTION == probeParser.parse(new int[]{kind},0)) { 
    660                     IToken last = getLastToken(); 
    661                     // and the last token is not a ")" or "{" 
    662                     //-- hack to fix bugs with island lexers (regex,xml) and virtual semicolon 
    663                     //-- for most of the control statements  
    664                     //-- see http://axdt.org/ticket/151 for more info 
    665                     int lastLine = last.getLine(); 
    666                     switch (last.getKind()) { 
    667                     case AS3Parsersym.TK_LCURLY: break; 
    668                     case AS3Parsersym.TK_RPAREN: 
    669                         int lineOffset = lexStream.getLineOffset(lastLine-1); 
    670                         int nextLineOffset = lexStream.getLineOffset(lastLine); 
    671                         char[] chars = lexStream.getInputChars(); 
    672                         StringBuilder buf = new StringBuilder(nextLineOffset-lineOffset); 
    673                         for (int i=lineOffset; i < chars.length && i < nextLineOffset; i++) { 
    674                            buf.append(chars[i]); 
    675                         } 
    676                         String result = buf.toString().trim(); 
    677                         if (result.contains("if")||result.contains("while")||result.contains("for")||result.contains("do")||result.contains("with")) { 
    678                             break; 
    679                         } 
    680                     default: 
    681                         int newLine = lexStream.getLineNumberOfCharAt(startLoc);  
    682                         // and there is a linebreak 
    683                         if (newLine>lastLine) { 
    684                             int action = probeParser.parse(new int[]{$_VirtualSemicolon},0); 
    685                             // and the error goes away if we probe with the virtual semi 
    686                             // every criteria is met to merge the virtual semi into the token stream 
    687                             if (action != ERROR_ACTION) { 
    688                                 int end = last.getEndOffset(); 
    689                                 lexStream.makeToken(end+1, end, $_VirtualSemicolon); 
    690                             } 
    691                         } 
    692                     } 
    693                 } 
    694             } 
    695             if (kind == $_LT) { 
    696                 //check for xml 
    697                 XmlAst xml = getXmlParser().parser(null,startLoc); 
    698                 if (xml != null) { 
    699                     lexStream.makeToken(xml.start, xml.end, $_Xml); 
    700                     lexStream.reset(xml.end+1); 
    701                     lexParser.resetTokenStream(xml.end+1); 
    702                     return; 
    703                 } 
    704             } else if ((kind == $_DIV || kind == $_DIV_ASSIGN) && canBeRegex(getLastToken())) { 
    705                 //check for xml 
    706                 RegexAst regex = getRegexParser().parser(null,startLoc); 
    707                 if (regex != null) { 
    708                     lexStream.makeToken(regex.start, regex.start, $_DIV_RX); 
    709                     lexStream.makeToken(regex.start+1, regex.end, $_RegularExpression); 
    710                     lexStream.reset(regex.end+1); 
    711                     lexParser.resetTokenStream(regex.end+1); 
    712                     return; 
    713                 } 
    714             } 
    715             lexStream.makeToken(startLoc, endLoc, kind); 
    716         } 
    717         public void lexer(Monitor monitor, AS3Parser as3parser, boolean probeVirtualSemi) { 
    718             ERROR_ACTION = as3parser.getParseTable().getErrorAction(); 
    719             insertVirtualSemicolon = probeVirtualSemi; 
    720             if (probeVirtualSemi) { 
    721                 probeParser = as3parser.getParser(); 
    722                 probeParser.resetParser(); 
    723             } 
    724             lexer(monitor, as3parser.getIPrsStream()); 
    725         } 
    726         // 
    727         // The Lexer contains an array of characters as the input stream to be parsed. 
    728         // There are methods to retrieve and classify characters. 
    729         // The lexparser "token" is implemented simply as the index of the next character in the array. 
    730         // The Lexer extends the abstract class LpgLexStream with an implementation of the abstract 
    731         // method getKind.  The template defines the Lexer class and the lexer() method. 
    732         // A driver creates the action class, "Lexer", passing an Option object to the constructor. 
    733         // 
    734         $kw_lexer_class kwLexer; 
    735         private final static int ECLIPSE_TAB_VALUE = 4; 
    736  
    737         public int [] getKeywordKinds() { return kwLexer.getKeywordKinds(); } 
    738  
    739         public $action_type(String filename) throws java.io.IOException 
    740         { 
    741             this(filename, ECLIPSE_TAB_VALUE); 
    742             this.kwLexer = new $kw_lexer_class(lexStream.getInputChars(), $_IDENTIFIER); 
    743         }         
    744          
    745         /** 
    746          * @deprecated function replaced by {@link #reset(char [] content, String filename)} 
    747          */ 
    748         public void initialize(char [] content, String filename) { 
    749             reset(content, filename); 
    750         } 
    751          
    752         final void makeToken(int kind) { 
    753             int startOffset = getLeftSpan(), 
    754                 endOffset = getRightSpan(); 
    755             makeToken(startOffset, endOffset, kind); 
    756         } 
    757  
    758         final void makeComment(int kind) { 
    759             int startOffset = getLeftSpan(), 
    760                 endOffset = getRightSpan(); 
    761             lexStream.getIPrsStream().makeAdjunct(startOffset, endOffset, kind); 
    762         } 
    763          
    764         public void makeBom() { 
    765             // if not at the beginning add a token so the user sees an error  
    766             if (getLeftSpan()!=0) { 
    767                 makeToken($_BOM); 
    768             } 
    769         } 
    770         final void skipToken() { } 
    771          
    772         final void checkForKeyWord() { 
    773             int startOffset = getLeftSpan(), 
    774                 endOffset = getRightSpan(), 
    775             kwKind = kwLexer.lexer(startOffset, endOffset); 
    776             makeToken(startOffset, endOffset, kwKind); 
    777         } 
    778  
    779         final void checkForKeyWord(int defaultKind) { 
    780             int startOffset = getLeftSpan(), 
    781                 endOffset = getRightSpan(), 
    782                 kwKind = kwLexer.lexer(startOffset, endOffset); 
    783             if (kwKind == $_IDENTIFIER) 
    784                 kwKind = defaultKind; 
    785             lexStream.makeToken(startOffset, endOffset, kwKind); 
    786         } 
     619            private AS3LexHelper make; 
     620            protected AS3KWLexer kwLexer; 
     621         
     622            public AS3Lexer(String filename) throws java.io.IOException { 
     623                this(filename, AS3LexHelper.TAB_VALUE); 
     624                this.kwLexer = new AS3KWLexer(lexStream.getInputChars(), $_IDENTIFIER); 
     625            } 
     626         
     627            public boolean lexer(Monitor monitor, AS3Parser as3parser) { 
     628                make = new AS3LexHelper(this); 
     629                make.init(as3parser); 
     630                IPrsStream prsStream = as3parser.getIPrsStream(); 
     631                initializeLexer(prsStream, 0, -1); 
     632                lexParser.parseCharacters(monitor); 
     633                make.eof(); 
     634                return !make.detectedError; 
     635            } 
     636            public int [] getKeywordKinds() { 
     637                return kwLexer.getKeywordKinds(); 
     638            }   
     639            /** 
     640             * @deprecated function replaced by {@link #reset(char [] content, String filename)} 
     641             */ 
     642            public void initialize(char [] content, String filename) { 
     643                reset(content, filename); 
     644            } 
    787645./%End 
    788646%Include 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/AS3ParseController.java

    r364575f rb32f7a4  
    102102 
    103103                // Lex the stream to produce the token stream 
    104                 lexer.lexer(my_monitor, parser, true);  
     104                lexer.lexer(my_monitor, parser);  
    105105                // fCurrentAst might (probably will) be 
    106106                // inconsistent wrt the lex stream now 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Parser.g

    r25b5d22 rb32f7a4  
    2929%End 
    3030 
     31%Ast 
     32%End 
     33 
    3134%Terminals 
    32     -- List of terminals needed by this grammar 
    33     as break case catch class const continue  
    34     default delete do else extends false finally for function  
    35     if implements import in instanceof interface internal is  
    36     new null package private protected public  
    37     return super switch this throw --to  
    38         true try typeof  
     35-- List of terminals needed by this grammar 
     36-- Keyword terminals 
     37    as break case catch class const continue 
     38    default delete do else extends false finally for function 
     39    if implements import in instanceof interface internal is 
     40    new null package private protected public 
     41    return super switch this throw true try typeof 
    3942    use var void while with 
    40     -- 
     43-- Soft keyword terminals 
    4144    each get set namespace include  
    4245    dynamic final native  
    43     override static 
    44     -- 
    45     --intrinsic   
    46     prototype xml -- enumerable explicit  
    47  
     46    override prototype static to  
     47-- Soft keyword terminals not in the spec 
     48    xml --intrinsic enumerable explicit  
     49-- Literal terminals 
    4850    IDENTIFIER 
    4951    String 
    5052    Number 
    5153    RegularExpression 
    52  
    53 --    SlComment 
    54 --    MlComment 
    55  
    56 --    NO_LINE_BREAK 
    57 --    VirtualSemicolon 
    58  
    59     QUESTION ::= '?' 
    60     LPAREN ::= '(' 
    61     RPAREN ::= ')' 
    62     LBRACK ::= '[' 
    63     RBRACK ::= ']' 
    64     LCURLY ::= '{' 
    65     RCURLY ::= '}' 
    66     DBL_COLON ::= '::' 
    67     COLON ::= ':' 
    68     COMMA ::= ',' 
    69     ASSIGN ::= '=' 
    70     EQUAL ::= '==' 
    71     STRICT_EQUAL ::= '===' 
    72     LNOT ::= '!' 
    73     BNOT ::= '~' 
    74     NOT_EQUAL ::= '!=' 
    75     STRICT_NOT_EQUAL ::= '!==' 
    76     DIV ::= '/' 
    77     DIV_RX 
    78     DIV_ASSIGN ::= '/=' 
    79     PLUS ::= '+' 
    80     PLUS_ASSIGN ::= '+=' 
    81     INC ::= '++' 
    82     MINUS ::= '-' 
    83     MINUS_ASSIGN ::= '-=' 
    84     DEC ::= '--' 
    85     STAR ::= '*' 
    86     STAR_ASSIGN  ::= '*=' 
    87     MOD ::= '%' 
    88     MOD_ASSIGN ::= '%=' 
    89     SR ::= '>>' 
    90     SR_ASSIGN ::= '>>=' 
    91     BSR ::= '>>>' 
    92     BSR_ASSIGN ::= '>>>=' 
    93     GE ::= '>=' 
    94     GT ::= '>' 
    95     SL ::= '<<' 
    96     SL_ASSIGN ::= '<<=' 
    97     LE ::= '<=' 
    98     LT ::= '<' 
    99     BXOR ::= '^' 
    100     BXOR_ASSIGN ::= '^=' 
    101     LXOR_ASSIGN ::= '^^=' 
    102     BOR ::= '|' 
    103     BOR_ASSIGN ::= '|=' 
    104     LOR ::= '||' 
    105     LOR_ASSIGN ::= '||=' 
    106     BAND ::= '&' 
    107     BAND_ASSIGN ::= '&=' 
    108     LAND ::= '&&' 
    109     LAND_ASSIGN ::= '&&=' 
    110     E4X_ATTRI ::= '@' 
    111     SEMI ::= ';' 
    112     DOT ::= '.' 
    113     E4X_DESC ::= '..' 
    114     REST ::= '...' 
     54        Xml 
     55-- Special terminals 
     56    NO_LINE_BREAK 
     57    VirtualSemicolon 
     58-- Punctuation terminals 
     59        QUESTION ::= '?' 
     60        LPAREN ::= '('        RPAREN ::= ')' 
     61        LBRACK ::= '['        RBRACK ::= ']' 
     62        LCURLY ::= '{'        RCURLY ::= '}' 
     63        COLON ::= ':'         DBL_COLON ::= '::' 
     64        COMMA ::= ',' 
     65        ASSIGN ::= '=' 
     66        EQUAL ::= '=='        STRICT_EQUAL ::= '===' 
     67        LNOT ::= '!'          BNOT ::= '~' 
     68        NOT_EQUAL ::= '!='    STRICT_NOT_EQUAL ::= '!==' 
     69        DIV ::= '/'           DIV_ASSIGN ::= '/=' 
     70        PLUS ::= '+'          PLUS_ASSIGN ::= '+=' 
     71        MINUS ::= '-'         MINUS_ASSIGN ::= '-=' 
     72        INC ::= '++'          DEC ::= '--' 
     73        STAR ::= '*'          STAR_ASSIGN  ::= '*=' 
     74        MOD ::= '%'           MOD_ASSIGN ::= '%=' 
     75        SR ::= '>>'           SR_ASSIGN ::= '>>=' 
     76        BSR ::= '>>>'         BSR_ASSIGN ::= '>>>=' 
     77        SL ::= '<<'           SL_ASSIGN ::= '<<=' 
     78        LT ::= '<'            LE ::= '<=' 
     79        GT ::= '>'            GE ::= '>=' 
     80        BXOR ::= '^'          BXOR_ASSIGN ::= '^=' 
     81        LXOR_ASSIGN ::= '^^=' 
     82        BOR ::= '|'           BOR_ASSIGN ::= '|=' 
     83        LOR ::= '||'          LOR_ASSIGN ::= '||=' 
     84        BAND ::= '&'          BAND_ASSIGN ::= '&=' 
     85        LAND ::= '&&'         LAND_ASSIGN ::= '&&=' 
     86        E4X_ATTRI ::= '@' 
     87        SEMI ::= ';' 
     88        DOT ::= '.' 
     89        E4X_DESC ::= '..' 
     90        REST ::= '...' 
    11591%End 
    11692 
     
    12399 
    124100%Rules 
    125 --no_line_break ::= NO_LINE_BREAK 
    126101-- 14 Expressions 
    127102-- opt, W = B = {allowin, noin} 
    128103-- 14.1 Identifiers 
    129104Identifier$Ident ::= IDENTIFIER$Token 
    130 Identifier$Ident ::= each$Token 
    131 Identifier$Ident ::= get$Token 
    132 Identifier$Ident ::= set$Token 
    133 Identifier$Ident ::= namespace$Token 
    134 Identifier$Ident ::= include$Token 
     105Identifier$Ident ::= final$Token 
    135106Identifier$Ident ::= dynamic$Token 
    136107Identifier$Ident ::= static$Token 
    137 Identifier$Ident ::= xml$Token 
     108Identifier$Ident ::= prototype$Token 
    138109Identifier$Ident ::= override$Token 
    139 Identifier$Ident ::= final$Token 
    140 Identifier$Ident ::= prototype$Token 
    141110Identifier$Ident ::= native$Token 
    142111/. 
     
    169138PrimaryExpression ::= Literal 
    170139PrimaryExpression ::= QualifiedIdentifier 
    171 --PrimaryExpression ::= ReservedNamespace --? 
     140PrimaryExpression ::= ReservedNamespace 
    172141PrimaryExpression ::= ParenListExpression 
    173142PrimaryExpression ::= ArrayInitialiser 
     
    184153Literal$BooleanLiteral ::= true$Token 
    185154Literal$BooleanLiteral ::= false$Token 
    186 Literal$RegexLiteral ::= DIV_RX$ RegularExpression$Token 
     155Literal$RegexLiteral ::= RegularExpression$Token 
    187156Literal$NullLiteral ::= null$Token 
    188157 
     
    210179ObjectInitialiser$ObjectInitialiser ::= LCURLY$ NonemptyFieldList$Fields RCURLY$ 
    211180ObjectInitialiser$ObjectInitialiser ::= LCURLY$ RCURLY$ 
    212 NonemptyFieldList$$LiteralField ::= LiteralField 
    213 NonemptyFieldList$$LiteralField ::= LiteralField COMMA$ NonemptyFieldList 
     181NonemptyFieldList$NonemptyFieldList$LiteralField ::= LiteralField 
     182NonemptyFieldList$NonemptyFieldList$LiteralField ::= LiteralField COMMA$ NonemptyFieldList 
    214183LiteralField ::= FieldName COLON$ AssignmentExpression_allowin$AssignmentExpression 
    215184FieldName$FieldName ::= NonAttributeQualifiedIdentifier 
     
    219188-- 14.7 Array initialiser 
    220189ArrayInitialiser ::= LBRACK$ ElementList RBRACK$ 
    221 ElementList$$LiteralElement ::= %empty 
    222 ElementList$$LiteralElement ::= LiteralElement 
    223 ElementList$$LiteralElement ::= COMMA$ ElementList 
    224 ElementList$$LiteralElement ::= LiteralElement COMMA$ ElementList 
     190ElementList$ElementList$LiteralElement ::= %empty 
     191ElementList$ElementList$LiteralElement ::= LiteralElement 
     192ElementList$ElementList$LiteralElement ::= COMMA$ ElementList 
     193ElementList$ElementList$LiteralElement ::= LiteralElement COMMA$ ElementList   
    225194LiteralElement ::= AssignmentExpression_noin 
    226195 
     
    231200 
    232201--14.10 Postfix Expressions 
    233 PostfixExpression ::= FullPostfixExpression 
    234 PostfixExpression ::= ShortNewExpression 
     202PostfixExpression ::= FullPostfixExpression | ShortNewExpression 
    235203 
    236204FullPostfixExpression ::= PrimaryExpression 
     
    240208FullPostfixExpression$Invocation ::= FullPostfixExpression$Expression Arguments 
    241209FullPostfixExpression$Query ::= FullPostfixExpression$Expression QueryOperator$Query 
    242 FullPostfixExpression$PostIncrementExpression ::= PostfixExpression$Expression --no_line_break$  
    243                                                 INC$ 
    244 FullPostfixExpression$PostDecrementExpression ::= PostfixExpression$Expression --no_line_break$  
    245                                                 DEC$ 
     210FullPostfixExpression$PostIncrementExpression ::= PostfixExpression$Expression --NO_LINE_BREAK$  
     211INC$ 
     212FullPostfixExpression$PostDecrementExpression ::= PostfixExpression$Expression --NO_LINE_BREAK$  
     213DEC$ 
    246214 
    247215--14.11 New expressions  
     
    309277RelationalExpression_allowin$RelationalExpression  
    310278        ::= RelationalExpression_allowin$Left 
    311             RelationalOpWithIn$Op ShiftExpression$Right 
     279            RelationalOperator_allowin$Op ShiftExpression$Right 
    312280 
    313281RelationalExpression_noin ::= ShiftExpression 
    314282RelationalExpression_noin$RelationalExpression  
    315283        ::= RelationalExpression_noin$Left 
    316             RelationalOperator$Op ShiftExpression$Right 
    317  
    318 RelationalOperator$RelationalOperator 
     284            RelationalOperator_noin$Op ShiftExpression$Right 
     285 
     286RelationalOperator_noin$RelationalOperator 
    319287        ::= LT$Token 
    320288          | GT$Token 
     
    324292          | is$Token 
    325293          | as$Token 
    326  
    327 RelationalOpWithIn ::= RelationalOperator 
    328 RelationalOpWithIn$RelationalOperator 
    329         ::= in$Token 
     294RelationalOperator_allowin$RelationalOperator 
     295        ::= LT$Token 
     296          | GT$Token 
     297          | LE$Token 
     298          | GE$Token 
     299          | instanceof$Token 
     300          | is$Token 
     301          | as$Token 
     302          | in$Token 
    330303 
    331304-- 14.16.5 Equality expressions --B 
     
    460433-- 14.20 List expressions 
    461434 --B 
    462 ListExpression_allowin$$AssignmentExpression_allowin 
     435ListExpression_allowin$ListExpression$AssignmentExpression 
    463436        ::= AssignmentExpression_allowin 
    464437          | ListExpression_allowin COMMA$ AssignmentExpression_allowin 
    465438 
    466 ListExpression_noin$$AssignmentExpression_noin  
     439ListExpression_noin$ListExpression$AssignmentExpression  
    467440        ::= AssignmentExpression_noin 
    468441          | ListExpression_noin COMMA$ AssignmentExpression_noin 
     
    472445TypeExpression_noin ::= NonAssignmentExpression_noin 
    473446 
    474 -- 15 Statements -- W = {_abbrev, _nosif, _full} 
    475 Statement_abbrev ::= Block 
    476           | IfStatement_abbrev 
     447-- 15 Statements -- W = {_sif, _nosif} 
     448-- remove _abbrev and _full we can insert a virtual semi before RCURLY instead 
     449-- the normal mode with short if is _sif 
     450Statement_sif ::= Block 
     451          | IfStatement_sif 
    477452          | SwitchStatement 
    478           | WhileStatement_abbrev 
    479           | ForStatement_abbrev 
    480           | WithStatement_abbrev 
     453          | WhileStatement_sif 
     454          | ForStatement_sif 
     455          | WithStatement_sif 
    481456          | TryStatement 
    482           | LabeledStatement_abbrev 
     457          | LabeledStatement_sif 
    483458          | DefaultXMLNamespaceStatement 
    484           | SuperStatement_abbrev 
    485           | DoStatement_abbrev 
    486           | ContinueStatement_abbrev 
    487           | BreakStatement_abbrev 
    488           | ReturnStatement_abbrev 
    489           | ThrowStatement_abbrev 
    490           | ExpressionStatement_abbrev 
     459          | SuperStatement 
     460          | DoStatement 
     461          | ContinueStatement 
     462          | BreakStatement 
     463          | ReturnStatement 
     464          | ThrowStatement 
     465          | ExpressionStatement 
    491466 
    492467Statement_nosif ::= Block 
     
    499474          | LabeledStatement_nosif 
    500475          | DefaultXMLNamespaceStatement 
    501           | SuperStatement_nosif 
    502           | DoStatement_nosif 
    503           | ContinueStatement_nosif 
    504           | BreakStatement_nosif 
    505           | ReturnStatement_nosif 
    506           | ThrowStatement_nosif 
    507           | ExpressionStatement_nosif 
    508  
    509 Statement_full ::= Block 
    510           | IfStatement_full 
    511           | SwitchStatement 
    512           | WhileStatement_full 
    513           | ForStatement_full 
    514           | WithStatement_full 
    515           | TryStatement 
    516           | LabeledStatement_full 
    517           | DefaultXMLNamespaceStatement 
    518           | SuperStatement_full 
    519           | DoStatement_full 
    520           | ContinueStatement_full 
    521           | BreakStatement_full 
    522           | ReturnStatement_full 
    523           | ThrowStatement_full 
    524           | ExpressionStatement_full 
     476          | SuperStatement 
     477          | DoStatement 
     478          | ContinueStatement 
     479          | BreakStatement 
     480          | ReturnStatement 
     481          | ThrowStatement 
     482          | ExpressionStatement 
    525483 
    526484 --W  
    527 Substatement_abbrev$Substatement 
     485Substatement_sif$Substatement 
    528486        ::= EmptyStatment 
    529           | Statement_abbrev 
    530           | VariableDefinition_allowin Semicolon_abbrev$ 
    531           | Attributes --no_line_break$  
    532                 LCURLY$ Substatements RCURLY$ 
     487          | Statement_sif 
     488          | VariableDefinition_allowin 
     489          | Attributes --NO_LINE_BREAK$  
     490                LCURLY$ Substatements RCURLY$ 
     491 
    533492Substatement_nosif$Substatement 
    534493        ::= EmptyStatment 
    535494          | Statement_nosif 
    536           | VariableDefinition_allowin Semicolon_nosif$ 
    537           | Attributes --no_line_break$  
    538                 LCURLY$ Substatements RCURLY$ 
    539 Substatement_full$Substatement 
    540         ::= EmptyStatment 
    541           | Statement_full 
    542           | VariableDefinition_allowin Semicolon_full$ 
    543           | Attributes --no_line_break$  
    544                 LCURLY$ Substatements RCURLY$ 
    545  
    546 Substatements ::= %empty 
    547 Substatements ::= SubstatementsPrefix Substatement_abbrev 
    548  
    549 SubstatementsPrefix$$Substatement_full ::= %empty 
    550 SubstatementsPrefix$$Substatement_full ::= SubstatementsPrefix Substatement_full 
    551  
    552 -- no empty semicolon ! use virtual semi now instead ! 
    553 --Semicolon_abbrev ::= %empty 
    554 Semicolon_abbrev$Semicolon ::= SEMI$ | VirtualSemicolon$ 
    555  
    556 --Semicolon_nosif ::= %empty 
    557 Semicolon_nosif$Semicolon ::= SEMI$ | VirtualSemicolon$ 
    558  
    559 Semicolon_full$Semicolon ::= SEMI$ | VirtualSemicolon$ 
     495          | VariableDefinition_allowin 
     496          | Attributes --NO_LINE_BREAK$  
     497                LCURLY$ Substatements RCURLY$ 
     498 
     499Substatements$Substatements$Substatement ::= %empty 
     500Substatements$Substatements$Substatement ::= Substatements Substatement_sif 
     501 
     502-- no empty semicolon ! use virtual semi instead ! 
     503-- virtual semi is inserted before RCURLY 
     504Semicolon$ ::= SEMI$ | VirtualSemicolon$ 
    560505 
    561506-- 15.1 Empty statement 
     
    565510--ExpressionStatement ::= ListExpression -- la ! function --allowin 
    566511--ExpressionStatement$ExpressionStatement ::= AssignmentExpression_allowin 
    567 ExpressionStatement_abbrev$ExpressionStatement 
    568         ::= AssignmentExpression_allowin$Expression Semicolon_abbrev$ 
    569 ExpressionStatement_nosif$ExpressionStatement 
    570         ::= AssignmentExpression_allowin$Expression Semicolon_nosif$ 
    571 ExpressionStatement_full$ExpressionStatement 
    572         ::= AssignmentExpression_allowin$Expression Semicolon_full$ 
     512ExpressionStatement$ExpressionStatement 
     513        ::= AssignmentExpression_allowin$Expression Semicolon$ 
    573514 
    574515-- 15.3 Super statement 
    575516--SuperStatement$SuperStatement ::= super$ Arguments  
    576 SuperStatement_abbrev$SuperStatement ::= super$ Arguments Semicolon_abbrev$ 
    577 SuperStatement_nosif$SuperStatement ::= super$ Arguments Semicolon_nosif$ 
    578 SuperStatement_full$SuperStatement ::= super$ Arguments Semicolon_full$ 
     517SuperStatement$SuperStatement ::= super$ Arguments Semicolon$ 
    579518 
    580519-- 15.4 Block statement 
    581 Block$Block ::= LCURLY$ Directives$Heads Directive_abbrev$Tail RCURLY$ 
    582 Block$Block ::= LCURLY$ Directive_abbrev$Tail RCURLY$ 
     520Block$Block ::= LCURLY$ Directives$Directives RCURLY$ 
    583521Block$Block ::= LCURLY$ RCURLY$ 
    584522/. 
     
    593531        public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 
    594532        public SymbolTable getSymbolTable() { return symbolTable; } 
    595         public DirectiveList getDirectives() { 
    596                 if (_Tail!=null) { 
    597                         if (_Heads != null) _Heads.add((IDirective) _Tail); 
    598                         else _Heads = new DirectiveList((IDirective) _Tail,true); 
    599                         _Tail = null; 
    600                 } 
    601                 return _Heads;  
    602         } 
    603533./ 
    604534 
    605535-- 15.5 Labeled statement 
    606536 --W 
    607 LabeledStatement_abbrev$LabeledStatement ::= Identifier$Label COLON$ Substatement_abbrev$Statement 
     537LabeledStatement_sif$LabeledStatement ::= Identifier$Label COLON$ Substatement_sif$Statement 
    608538LabeledStatement_nosif$LabeledStatement ::= Identifier$Label COLON$ Substatement_nosif$Statement 
    609 LabeledStatement_full$LabeledStatement ::= Identifier$Label COLON$ Substatement_full$Statement 
    610539 
    611540-- 15.6 Conditional statements 
    612541-- 15.6.1 If statement 
    613 IfStatement_abbrev$IfStatement ::= if$ ParenListExpression$Condition Substatement_abbrev$IfStatement 
    614 IfStatement_abbrev$IfStatement ::= if$ ParenListExpression$Condition Substatement_nosif$IfStatement else$ Substatement_abbrev$ElseStatement 
     542IfStatement_sif$IfStatement ::= if$ ParenListExpression$Condition Substatement_sif$IfStatement 
     543IfStatement_sif$IfStatement ::= if$ ParenListExpression$Condition Substatement_nosif$IfStatement else$ Substatement_sif$ElseStatement 
    615544 
    616545IfStatement_nosif$IfStatement ::= if$ ParenListExpression$Condition Substatement_nosif$IfStatement else$ Substatement_nosif$ElseStatement 
    617  
    618 IfStatement_full$IfStatement ::= if$ ParenListExpression$Condition Substatement_full$IfStatement 
    619 IfStatement_full$IfStatement ::= if$ ParenListExpression$Condition Substatement_nosif$IfStatement else Substatement_full$ElseStatement 
    620546 
    621547-- 15.6.2 Switch statement 
    622548SwitchStatement ::= switch$ ParenListExpression LCURLY$ CaseElements RCURLY$ 
    623 CaseElements ::= %empty 
    624 CaseElements ::= CaseLabel 
    625 CaseElements ::= CaseLabel CaseElementsPrefix CaseElement_abbrev 
    626 CaseElementsPrefix ::= %empty 
    627 CaseElementsPrefix ::= CaseElementsPrefix CaseElement_full 
     549CaseElements$CaseElements$CaseElement ::= %empty 
     550CaseElements$CaseElements$CaseElement ::= CaseElements CaseElement 
     551 
    628552 -- W 
    629 CaseElement_abbrev ::= Directive_abbrev | CaseLabel 
    630 --CaseElement_nosif ::= Directive_nosif | CaseLabel 
    631 CaseElement_full ::= Directive | CaseLabel 
     553CaseElement$CaseElement ::= Directive | CaseLabel 
    632554CaseLabel$CaseLabel ::= case$ ListExpression_allowin COLON$  
    633555CaseLabel$CaseLabel ::= default$ COLON$ 
     
    635557-- 15.7 Iteration statements 
    636558-- 15.7.1 Do-while statement 
    637 --DoStatement ::= do$ Substatement_abbrev$Statement while$ ParenListExpression$Condition 
    638 DoStatement_abbrev$DoStatement ::= do$ Substatement_abbrev$Statement while$ ParenListExpression$Condition Semicolon_abbrev$ 
    639 DoStatement_nosif$DoStatement ::= do$ Substatement_abbrev$Statement while$ ParenListExpression$Condition Semicolon_nosif$ 
    640 DoStatement_full$DoStatement ::= do$ Substatement_abbrev$Statement while$ ParenListExpression$Condition Semicolon_full$ 
     559DoStatement$DoStatement ::= do$ Substatement_sif$Statement while$ ParenListExpression$Condition Semicolon$ 
    641560 
    642561-- 15.7.2 While statement --W 
    643 WhileStatement_abbrev$WhileStatement  
    644         ::= while$ ParenListExpression$Condition Substatement_abbrev$Statement 
     562WhileStatement_sif$WhileStatement  
     563        ::= while$ ParenListExpression$Condition Substatement_sif$Statement 
    645564WhileStatement_nosif$WhileStatement  
    646565        ::= while$ ParenListExpression$Condition Substatement_nosif$Statement 
    647 WhileStatement_full$WhileStatement  
    648         ::= while$ ParenListExpression$Condition Substatement_full$Statement 
    649566 
    650567-- 15.7.3 For statements 
    651568 --W  
    652 ForStatement_abbrev$ForStatement  
    653         ::= for$ LPAREN$ ForInitializer SEMI$ OptionalExpression SEMI$ OptionalExpression RPAREN$ Substatement_abbrev 
    654           | for$ LPAREN$ ForInBinding in ListExpression_allowin RPAREN$ Substatement_abbrev 
    655           | for$ --no_line_break$  
    656                 each$ LPAREN$ ForInBinding in ListExpression_allowin RPAREN$ Substatement_abbrev 
     569ForStatement_sif$ForStatement  
     570        ::= for$ LPAREN$ ForInitializer SEMI$ OptionalExpression SEMI$ OptionalExpression RPAREN$ Substatement_sif 
     571          | for$ LPAREN$ ForInBinding in ListExpression_allowin RPAREN$ Substatement_sif 
     572          | for$ NO_LINE_BREAK$ each$ LPAREN$ ForInBinding in ListExpression_allowin RPAREN$ Substatement_sif 
    657573ForStatement_nosif$ForStatement  
    658574        ::= for$ LPAREN$ ForInitializer SEMI$ OptionalExpression SEMI$ OptionalExpression RPAREN$ Substatement_nosif 
    659575          | for$ LPAREN$ ForInBinding in ListExpression_allowin RPAREN$ Substatement_nosif 
    660           | for$ --no_line_break$  
    661                 each$ LPAREN$ ForInBinding in ListExpression_allowin RPAREN$ Substatement_nosif 
    662 ForStatement_full$ForStatement  
    663         ::= for$ LPAREN$ ForInitializer SEMI$ OptionalExpression SEMI$ OptionalExpression RPAREN$ Substatement_full 
    664           | for$ LPAREN$ ForInBinding in ListExpression_allowin RPAREN$ Substatement_full 
    665           | for$ --no_line_break$  
    666                 each$ LPAREN$ ForInBinding in ListExpression_allowin RPAREN$ Substatement_full             
     576          | for$ NO_LINE_BREAK$ each$ LPAREN$ ForInBinding in ListExpression_allowin RPAREN$ Substatement_nosif 
    667577ForInitializer ::= %empty 
    668578ForInitializer ::= ListExpression_noin 
     
    676586 
    677587-- 15.8 Continue statement 
    678 --ContinueStatement$ContinueStatement  
    679 --      ::= continue$ | continue$ no_line_break$ Identifier$Label 
    680 ContinueStatement_abbrev$ContinueStatement  
    681         ::= continue$ Semicolon_abbrev$ 
    682           | continue$ --no_line_break$  
    683                 Identifier$Label Semicolon_abbrev$ 
    684 ContinueStatement_nosif$ContinueStatement  
    685         ::= continue$ Semicolon_nosif$ 
    686           | continue$ --no_line_break$  
    687                 Identifier$Label Semicolon_nosif$ 
    688 ContinueStatement_full$ContinueStatement  
    689         ::= continue$ Semicolon_full$ 
    690           | continue$ --no_line_break$  
    691                 Identifier$Label Semicolon_full$ 
     588ContinueStatement$ContinueStatement  
     589        ::= continue$ Semicolon$ 
     590          | continue$ NO_LINE_BREAK$ Identifier$Label Semicolon$ 
    692591 
    693592-- 15.9 Break statement 
    694593--BreakStatement$BreakStatement  
    695 --      ::= break$ | break$ no_line_break$ Identifier$Label 
    696 BreakStatement_abbrev$BreakStatement  
    697         ::= break$ Semicolon_abbrev$ 
    698           | break$ --no_line_break$  
    699                 Identifier$Label Semicolon_abbrev$ 
    700 BreakStatement_nosif$BreakStatement  
    701         ::= break$ Semicolon_nosif$ 
    702           | break$ --no_line_break$  
    703                 Identifier$Label Semicolon_nosif$ 
    704 BreakStatement_full$BreakStatement  
    705         ::= break$ Semicolon_full$ 
    706           | break$ --no_line_break$  
    707                 Identifier$Label Semicolon_full$ 
     594BreakStatement$BreakStatement  
     595        ::= break$ Semicolon$ 
     596          | break$ NO_LINE_BREAK$ Identifier$Label Semicolon$ 
    708597 
    709598-- 15.10 With statement 
    710599 --W 
    711 WithStatement_abbrev$WithStatement ::= with$ ParenListExpression Substatement_abbrev$Statement 
     600WithStatement_sif$WithStatement ::= with$ ParenListExpression Substatement_sif$Statement 
    712601WithStatement_nosif$WithStatement ::= with$ ParenListExpression Substatement_nosif$Statement 
    713 WithStatement_full$WithStatement ::= with$ ParenListExpression Substatement_full$Statement 
    714602 
    715603-- 15.11 Return statement 
    716 --ReturnStatement$ReturnStatement  
    717 --      ::= return$ | return$ no_line_break$ ListExpression_allowin 
    718 ReturnStatement_abbrev$ReturnStatement  
    719         ::= return$ Semicolon_abbrev$ 
    720           | return$ --no_line_break$  
    721                 ListExpression_allowin  Semicolon_abbrev$ 
    722 ReturnStatement_nosif$ReturnStatement  
    723         ::= return$ Semicolon_nosif$ 
    724           | return$ --no_line_break$  
    725                 ListExpression_allowin Semicolon_nosif$ 
    726 ReturnStatement_full$ReturnStatement  
    727         ::= return$ Semicolon_full$ 
    728           | return$ --no_line_break$  
    729                 ListExpression_allowin Semicolon_full$ 
     604ReturnStatement$ReturnStatement  
     605        ::= return$ Semicolon$ 
     606          | return$ NO_LINE_BREAK$ ListExpression_allowin  Semicolon$ 
    730607 
    731608-- 15.12 Throw statement 
    732 --ThrowStatement ::= throw$ no_line_break$ ListExpression_allowin 
    733 ThrowStatement_abbrev$ThrowStatement 
    734         ::= throw$ --no_line_break$  
    735                 ListExpression_allowin Semicolon_abbrev$ 
    736 ThrowStatement_nosif$ThrowStatement 
    737         ::= throw$ --no_line_break$  
    738                 ListExpression_allowin Semicolon_nosif$ 
    739 ThrowStatement_full$ThrowStatement 
    740         ::= throw$ --no_line_break$  
    741                 ListExpression_allowin Semicolon_full$ 
     609ThrowStatement$ThrowStatement 
     610        ::= throw$ NO_LINE_BREAK$ ListExpression_allowin Semicolon$ 
    742611 
    743612-- 15.13 Try statement 
     
    746615CatchClausesOpt ::= CatchClauses 
    747616CatchClausesOpt ::= %empty 
    748 CatchClauses$$CatchClause ::= CatchClause 
    749 CatchClauses$$CatchClause ::= CatchClauses CatchClause 
     617CatchClauses$CatchClauses$CatchClause ::= CatchClause 
     618CatchClauses$CatchClauses$CatchClause ::= CatchClauses CatchClause 
    750619CatchClause ::= catch$ LPAREN$ PlainParameter RPAREN$ Block 
    751620 
    752621-- 15.14 Default XML namespace statement 
    753 DefaultXMLNamespaceStatement ::= default$ --no_line_break$  
    754                                 'xml'$ --no_line_break$  
     622DefaultXMLNamespaceStatement ::= default$ NO_LINE_BREAK$ xml$ NO_LINE_BREAK$  
    755623                                namespace$ ASSIGN$ NonAssignmentExpression_allowin 
    756624 
    757625-- 16 Directives --W 
    758 AnnotatedDirective_abbrev  
    759         ::= Attributes --no_line_break$  
    760                 AnnotatableDirective_abbrev 
    761         | AnnotatableDirective_abbrev 
    762 Directive_abbrev ::= AnnotatedDirective_abbrev 
    763           | EmptyStatment 
    764           | IncludeDirective 
    765           | ImportDirectives 
    766           | UseDirective 
    767           | Statement_abbrev 
    768  
    769626AnnotatedDirective 
    770         ::= Attributes --no_line_break$  
    771             AnnotatableDirective_full 
    772           | AnnotatableDirective_full 
     627        ::= Attributes --NO_LINE_BREAK$  
     628                AnnotatableDirective 
     629          | AnnotatableDirective 
    773630Directive ::= AnnotatedDirective 
    774631          | EmptyStatment 
    775632          | IncludeDirective 
    776           | ImportDirectives -- ignore we just want to group imports 
     633          | ImportDirectives --@ignore we just want to group imports  
    777634          | UseDirective 
    778           | Statement_full 
     635          | Statement_sif 
    779636 
    780637 --W 
    781 AnnotatableDirective_abbrev 
     638AnnotatableDirective 
    782639        ::= FunctionDefinition 
    783           | VariableDefinitionSemi_abbrev 
     640          | VariableDefinition_allowin 
    784641          | ClassDefinition 
    785642          | InterfaceDefinition 
    786643          | NamespaceDefinition 
    787644 
    788 AnnotatableDirective_full 
    789         ::= FunctionDefinition 
    790           | VariableDefinitionSemi_full 
    791           | ClassDefinition 
    792           | InterfaceDefinition 
    793           | NamespaceDefinition 
    794  
    795 VariableDefinitionSemi_abbrev ::= VariableDefinition_allowin Semicolon_abbrev$ 
    796 --VariableDefinitionSemi_nosif ::= VariableDefinition_allowin Semicolon_nosif$ 
    797 VariableDefinitionSemi_full ::= VariableDefinition_allowin Semicolon_full$ 
    798 Directives$$Directive ::= Directive 
    799 Directives$$Directive ::= Directives Directive 
    800  
    801 --DirectivesPrefix$$Directive_full ::= Directive_full 
    802 --DirectivesPrefix$$Directive_full ::= DirectivesPrefix Directive_full  
     645Directives$Directives$Directive ::= Directive 
     646Directives$Directives$Directive ::= Directives Directive 
    803647 
    804648-- 16.1 Attributes 
    805 Attributes$$Attribute ::= Attribute 
    806 Attributes$$Attribute ::= Attributes Attribute --AttributeCombination 
    807  
    808 --AttributeCombination$$Attribute ::= Attribute no_line_break$ Attributes 
     649Attributes$Attributes$Attribute ::= Attribute 
     650Attributes$Attributes$Attribute ::= Attributes --NO_LINE_BREAK$  
     651                                                                        Attribute 
    809652 
    810653Attribute ::= AttributeExpression 
     
    816659 
    817660-- 16.2 Import directive 
    818 ImportDirective$ImportDirective ::= import$ Name DOT$ STAR$OnDemand Semicolon_abbrev$ 
    819 ImportDirective$ImportDirective ::= import$ Name Semicolon_abbrev$ 
     661ImportDirective$ImportDirective ::= import$ Name DOT$ STAR$OnDemand Semicolon$ 
     662ImportDirective$ImportDirective ::= import$ Name Semicolon$ 
    820663 
    821664-- grouping 
    822 ImportDirectives$$ImportDirective  
     665ImportDirectives$ImportDirectives$ImportDirective  
    823666        ::= ImportDirective 
    824667          | ImportDirectives ImportDirective  
    825668 
    826669-- 16.3 Include directive 
    827 IncludeDirective ::= include$ --no_line_break$  
    828                         String Semicolon_abbrev$ 
     670IncludeDirective ::= include$ NO_LINE_BREAK$ String Semicolon$ 
    829671 
    830672-- 16.4 Use directive 
    831 UseDirective ::= use$ namespace$ ListExpression_allowin Semicolon_abbrev$ 
     673UseDirective ::= use$ namespace$ ListExpression_allowin Semicolon$ 
    832674 
    833675-- 17 Definitions 
    834676-- 17.1 Variable definition 
    835677 --B 
     678VariableDefinition_noin$VariableDefinition 
     679        ::= VariableDefinitionKind$Kind 
     680            VariableBindingList_noin$RawBindings 
    836681VariableDefinition_allowin$VariableDefinition 
    837682        ::= VariableDefinitionKind$Kind 
    838             VariableBindingList_allowin$Bindings 
    839 VariableDefinition_noin$VariableDefinition 
    840         ::= VariableDefinitionKind$Kind 
    841             VariableBindingList_noin$Bindings 
     683            VariableBindingList_allowin$RawBindings 
     684            Semicolon$ 
    842685/. 
    843         public AttributeList getAttributes() { 
     686    public AbstractASTNodeList getBindings() { 
     687                return _RawBindings instanceof IVariableBindingList  
     688                        ? (AbstractASTNodeList)_RawBindings : null;  
     689        } 
     690        public Attributes getAttributes() { 
    844691                if (!(getParent() instanceof AnnotatedDirective)) return null; 
    845692                return ((AnnotatedDirective) getParent()).getAttributes(); 
    846693        } 
    847694./ 
     695 
    848696VariableDefinitionKind$VarKind ::= var$Token 
    849697VariableDefinitionKind$ConstKind ::= const$Token 
    850698 
    851 VariableDefinitionSemi_abbrev$VariableDefinition 
    852         ::= VariableDefinitionKind$Kind 
    853             VariableBindingList_allowin$Bindings 
    854             Semicolon_abbrev$ 
    855 VariableDefinitionSemi_full$VariableDefinition 
    856         ::= VariableDefinitionKind$Kind 
    857             VariableBindingList_allowin$Bindings 
    858             Semicolon_full$ 
    859699--VariableMods$$VariableMod ::= %empty 
    860700--VariableMods$$VariableMod ::= VariableMods VariableMod 
     
    864704 
    865705 --B 
    866 VariableBindingList_allowin$$VariableBinding_allowin ::= VariableBinding_allowin 
    867 VariableBindingList_allowin$$VariableBinding_allowin ::= VariableBindingList_allowin COMMA$ VariableBinding_allowin 
    868  
    869 VariableBindingList_noin$$VariableBinding_noin ::= VariableBinding_noin 
    870 VariableBindingList_noin$$VariableBinding_noin ::= VariableBindingList_noin COMMA$ VariableBinding_noin 
     706VariableBindingList_allowin$VariableBindingsAllowin$VariableBinding_allowin ::= VariableBinding_allowin 
     707VariableBindingList_allowin$VariableBindingsAllowin$VariableBinding_allowin ::= VariableBindingList_allowin COMMA$ VariableBinding_allowin 
     708 
     709VariableBindingList_noin$VariableBindingsNoin$VariableBinding_noin ::= VariableBinding_noin 
     710VariableBindingList_noin$VariableBindingsNoin$VariableBinding_noin ::= VariableBindingList_noin COMMA$ VariableBinding_noin 
     711 
     712VariableBindingList ::= VariableBindingList_allowin | VariableBindingList_noin 
    871713 --B 
    872714VariableBinding_allowin$VariableBinding  
     
    874716VariableBinding_noin$VariableBinding  
    875717        ::= TypedIdentifier_noin$Ident VariableInitialisation_noin$Initializer 
     718 
    876719 --B 
    877720VariableInitialisation_allowin$VariableInitialisation 
     
    892735 
    893736-- 17.2 Function definition 
    894 FunctionDefinition$FunctionDefinition ::= function$ FunctionAccessor$Accessor --no_line_break$  
    895                                           Identifier$Name FunctionCommon$Common Block 
    896 FunctionDefinition$FunctionDefinition ::= function$ Identifier$Name FunctionCommon$Common Block 
     737FunctionDefinition$FunctionDefinition ::= function$ FunctionAccessor$Accessor Identifier$Name FunctionCommon$Common Block 
    897738/. 
    898739        public boolean isConstructor; 
     
    900741        public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 
    901742        public SymbolTable getSymbolTable() { return symbolTable; } 
    902         public AttributeList getAttributes() { 
     743        public Attributes getAttributes() { 
    903744                if (!(getParent() instanceof AnnotatedDirective)) return null; 
    904745                return ((AnnotatedDirective) getParent()).getAttributes(); 
    905746        } 
    906747./ 
    907 FunctionSignature$FunctionDefinition ::= function$ FunctionAccessor$Accessor --no_line_break$  
    908                                           Identifier$Name FunctionCommon$Common Semicolon_abbrev$ 
    909 FunctionSignature$FunctionDefinition ::= function$ Identifier$Name FunctionCommon$Common Semicolon_abbrev$ 
    910  
    911 FunctionAccessor$FunctionAccessor ::= get$Token 
    912 FunctionAccessor$FunctionAccessor ::= set$Token 
     748FunctionSignature$FunctionDefinition ::= function$ FunctionAccessor$Accessor Identifier$Name FunctionCommon$Common Semicolon$ 
     749 
     750FunctionAccessor ::= %empty 
     751FunctionAccessor$FunctionAccessor ::= get$Token NO_LINE_BREAK$ 
     752FunctionAccessor$FunctionAccessor ::= set$Token NO_LINE_BREAK$ 
    913753 
    914754--FunctionMods$$FunctionMod ::= %empty 
     
    930770 
    931771-- 17.2.3 Parameter list  
    932 Parameters$$Parameter ::= %empty 
    933 Parameters$$Parameter ::= NonemptyParameters 
    934 NonemptyParameters$$Parameter ::= Parameter 
    935 NonemptyParameters$$Parameter ::= PlainParameter COMMA$ NonemptyParameters 
     772Parameters$Parameters$Parameter ::= %empty 
     773Parameters$Parameters$Parameter ::= NonemptyParameters 
     774NonemptyParameters$Parameters$Parameter ::= Parameter 
     775NonemptyParameters$Parameters$Parameter ::= PlainParameter COMMA$ NonemptyParameters 
    936776Parameter ::= PlainParameter | RestParameter 
    937777PlainParameter$PlainParameter ::= TypedIdentifier_allowin$Ident 
     
    953793        public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 
    954794        public SymbolTable getSymbolTable() { return symbolTable; } 
    955         public AttributeList getAttributes() { 
     795        public Attributes getAttributes() { 
    956796                if (!(getParent() instanceof AnnotatedDirective)) return null; 
    957797                return ((AnnotatedDirective) getParent()).getAttributes(); 
     
    976816Inheritance$Inheritance ::= extends$ TypeExpression_allowin$Extends implements$ TypeExpressionList$Implements 
    977817 
    978 TypeExpressionList$$TypeExpression_allowin ::= TypeExpression_allowin 
    979 TypeExpressionList$$TypeExpression_allowin ::= TypeExpressionList COMMA$ TypeExpression_allowin 
     818TypeExpressionList$TypeExpressionList$TypeExpression_allowin ::= TypeExpression_allowin 
     819TypeExpressionList$TypeExpressionList$TypeExpression_allowin ::= TypeExpressionList COMMA$ TypeExpression_allowin 
    980820 
    981821-- 17.3.4 Class block 
     
    986826InterfaceDefinition ::= interface$ Name ExtendsList InterfaceBlock$Body 
    987827/. 
    988         public AttributeList getAttributes() { 
     828        public Attributes getAttributes() { 
    989829                if (!(getParent() instanceof AnnotatedDirective)) return null; 
    990830                return ((AnnotatedDirective) getParent()).getAttributes(); 
     
    1007847        public SymbolTable getSymbolTable() { return symbolTable; } 
    1008848./ 
    1009 InterfaceDirectives$$FunctionSignature ::= FunctionSignature 
    1010 InterfaceDirectives$$FunctionSignature ::= InterfaceDirectives FunctionSignature 
     849InterfaceDirectives$InterfaceDirectives$FunctionSignature ::= FunctionSignature 
     850InterfaceDirectives$InterfaceDirectives$FunctionSignature ::= InterfaceDirectives FunctionSignature 
    1011851-- 17.5 Package definition 
    1012852PackageDefinition$PackageDefinition ::= package$ Block$Body 
     
    1020860NamespaceDefinition$NamespaceDefinition ::= namespace$ Identifier$Name ASSIGN$ AssignmentExpression_allowin$Assignment 
    1021861/. 
    1022         public AttributeList getAttributes() { 
     862        public Attributes getAttributes() { 
    1023863                if (!(getParent() instanceof AnnotatedDirective)) return null; 
    1024864                return ((AnnotatedDirective) getParent()).getAttributes(); 
     
    1036876./ 
    1037877 
    1038 PackageDefinitions$$PackageDefinition ::= %empty 
    1039 PackageDefinitions$$PackageDefinition ::= PackageDefinitions PackageDefinition 
     878PackageDefinitions$PackageDefinitions$PackageDefinition ::= %empty 
     879PackageDefinitions$PackageDefinitions$PackageDefinition ::= PackageDefinitions PackageDefinition 
     880 
     881 
     882-- unused terminal to group types 
     883VariableDefinition ::= VariableDefinition_allowin | VariableDefinition_noin 
     884VariableBinding ::= VariableBinding_allowin | VariableBinding_noin 
     885Statement ::= Statement_sif | Statement_nosif 
     886Substatement ::= Substatement_sif | Substatement_nosif 
     887AssignmentExpression ::= AssignmentExpression_allowin | AssignmentExpression_noin 
    1040888%End 
    1041889 
     
    1046894 
    1047895%Types 
     896List ::= TypeExpressionList 
     897 
    1048898RelationalExpression ::= RelationalExpression_allowin | RelationalExpression_noin 
    1049899 
     
    1066916AssignmentExpression ::= AssignmentExpression_allowin | AssignmentExpression_noin 
    1067917 
    1068 --AssignmentExpressionList ::= AssignmentExpression_allowinList | AssignmentExpression_noinList 
    1069  
    1070918TypeExpression ::= TypeExpression_allowin | TypeExpression_noin 
    1071919 
    1072 Statement ::= Statement_abbrev | Statement_nosif | Statement_full 
    1073  
    1074 Substatement ::= Substatement_abbrev | Substatement_nosif | Substatement_full 
    1075  
    1076 Semicolon ::= Semicolon_abbrev | Semicolon_nosif | Semicolon_full 
    1077  
    1078 ExpressionStatement ::= ExpressionStatement_abbrev | ExpressionStatement_nosif | ExpressionStatement_full 
    1079  
    1080 SuperStatement ::= SuperStatement_abbrev | SuperStatement_nosif | SuperStatement_full 
    1081  
    1082 LabeledStatement ::= LabeledStatement_abbrev | LabeledStatement_nosif | LabeledStatement_full 
    1083  
    1084 IfStatement ::= IfStatement_abbrev | IfStatement_nosif | IfStatement_full 
    1085  
    1086 DoStatement ::= DoStatement_abbrev | DoStatement_nosif | DoStatement_full 
    1087  
    1088 WhileStatement ::= WhileStatement_abbrev | WhileStatement_nosif | WhileStatement_full 
    1089  
    1090 ForStatement ::= ForStatement_abbrev | ForStatement_nosif | ForStatement_full 
    1091  
    1092 ContinueStatement ::= ContinueStatement_abbrev | ContinueStatement_nosif | ContinueStatement_full 
    1093  
    1094 BreakStatement ::= BreakStatement_abbrev | BreakStatement_nosif | BreakStatement_full 
    1095  
    1096 WithStatement ::= WithStatement_abbrev | WithStatement_nosif | WithStatement_full 
    1097  
    1098 ReturnStatement ::= ReturnStatement_abbrev | ReturnStatement_nosif | ReturnStatement_full 
    1099  
    1100 ThrowStatement ::= ThrowStatement_abbrev | ThrowStatement_nosif | ThrowStatement_full 
    1101  
    1102 VariableDefinitionSemi ::= VariableDefinitionSemi_abbrev | VariableDefinitionSemi_full 
     920Statement ::= Statement_sif | Statement_nosif 
     921 
     922Substatement ::= Substatement_sif | Substatement_nosif 
     923 
     924ExpressionStatement ::= ExpressionStatement_sif | ExpressionStatement_nosif 
     925 
     926LabeledStatement ::= LabeledStatement_sif | LabeledStatement_nosif 
     927 
     928IfStatement ::= IfStatement_sif | IfStatement_nosif 
     929 
     930WhileStatement ::= WhileStatement_sif | WhileStatement_nosif 
     931 
     932ForStatement ::= ForStatement_sif | ForStatement_nosif 
     933 
     934WithStatement ::= WithStatement_sif | WithStatement_nosif 
    1103935%End 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTableVisitor.java

    r25b5d22 rb32f7a4  
    77 
    88import org.axdt.as3.imp.parser.Ast.AssignmentExpression; 
    9 import org.axdt.as3.imp.parser.Ast.AttributeList; 
     9import org.axdt.as3.imp.parser.Ast.Attributes; 
    1010import org.axdt.as3.imp.parser.Ast.Block; 
    1111import org.axdt.as3.imp.parser.Ast.ClassDefinition; 
     
    9191                        name = n.getAccessor().toString() + " " + name; 
    9292                } 
    93                 AttributeList attributes = n.getAttributes(); 
     93                Attributes attributes = n.getAttributes(); 
    9494                if (attributes != null) { 
    9595                        for (Object o:n.getAttributes().getArrayList()) { 
     
    152152                if (parent instanceof VariableDefinition) { 
    153153                        VariableDefinition f = (VariableDefinition) parent; 
    154                         AttributeList attributes = f.getAttributes(); 
     154                        Attributes attributes = f.getAttributes(); 
    155155                        if (attributes != null) { 
    156156                                for (Object o:f.getAttributes().getArrayList()) { 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/regex/RegexAst.java

    re9006de rb32f7a4  
    11package org.axdt.as3.imp.parser.regex; 
    22 
    3 public class RegexAst { 
     3import org.axdt.as3.imp.parser.HelperAst; 
    44 
    5         public final int start; 
    6         public final int end; 
     5public class RegexAst extends HelperAst { 
    76 
    87        public RegexAst(RegexAst ast) { 
    9                 this.start = ast.start; 
    10                 this.end = ast.end; 
     8                super(ast); 
    119        } 
    1210 
    1311        public RegexAst(int start, int end) { 
    14                 this.start = start; 
    15                 this.end = end; 
    16         } 
    17  
    18         @Override 
    19         public boolean equals(Object obj) { 
    20                 if (null == obj) return false; 
    21                 if (this == obj) return true; 
    22                 if (obj.getClass().equals(RegexAst.class)){ 
    23                         RegexAst other = (RegexAst) obj; 
    24                         return start == other.start 
    25                                 && end == other.end; 
    26                 } 
    27                 return super.equals(obj); 
    28         } 
    29  
    30         @Override 
    31         public String toString() { 
    32                 return "xml:"+start+":"+end; 
     12                super(start, end); 
    3313        } 
    3414} 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/regex/RegexParser.g

    ra106cc3 rb32f7a4  
    1212%options single_productions 
    1313%options package=org.axdt.as3.imp.parser.regex 
    14 %options template=LexerTemplateF.gi 
     14%options template=LexerTemplate.ggg 
    1515%options ast_type=RegexAst 
    1616 
     
    188188                return result; 
    189189        } 
    190         public void reset(LpgLexStream stream) { 
     190        public void reset(lpg.runtime.LexStream stream) { 
    191191                reset(stream.getInputChars(),stream.getFileName(),stream.getTab()); 
    192192                lexStream.setMessageHandler(org.axdt.as3.imp.parser.AS3MessageHandler.NULL_MESSAGE_HANDLER); 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/xml/XmlAst.java

    re9006de rb32f7a4  
    11package org.axdt.as3.imp.parser.xml; 
    22 
    3 public class XmlAst { 
     3import org.axdt.as3.imp.parser.HelperAst; 
    44 
    5         public final int start; 
    6         public final int end; 
     5public class XmlAst extends HelperAst { 
    76 
    87        public XmlAst(XmlAst ast) { 
    9                 this.start = ast.start; 
    10                 this.end = ast.end; 
     8                super(ast); 
    119        } 
    1210 
    1311        public XmlAst(int start, int end) { 
    14                 this.start = start; 
    15                 this.end = end; 
    16         } 
    17  
    18         @Override 
    19         public boolean equals(Object obj) { 
    20                 if (null == obj) return false; 
    21                 if (this == obj) return true; 
    22                 if (obj.getClass().equals(XmlAst.class)){ 
    23                         XmlAst other = (XmlAst) obj; 
    24                         return start == other.start 
    25                                 && end == other.end; 
    26                 } 
    27                 return super.equals(obj); 
    28         } 
    29  
    30         @Override 
    31         public String toString() { 
    32                 return "xml:"+start+":"+end; 
     12                super(start, end); 
    3313        } 
    3414} 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/xml/XmlParser.g

    ra106cc3 rb32f7a4  
    1111%options single_productions 
    1212%options package=org.axdt.as3.imp.parser.xml 
    13 %options template=LexerTemplateF.gi 
     13%options template=LexerTemplate.ggg 
    1414%options ast_type=XmlAst 
    1515 
     
    312312                return result; 
    313313        } 
    314         public void reset(LpgLexStream stream) { 
     314        public void reset(lpg.runtime.LexStream stream) { 
    315315                reset(stream.getInputChars(),stream.getFileName(),stream.getTab()); 
    316316                lexStream.setMessageHandler(org.axdt.as3.imp.parser.AS3MessageHandler.NULL_MESSAGE_HANDLER); 
  • org.axdt.as3/src/org/axdt/as3/imp/services/AS3ContentProposer.java

    r1567fcc rb32f7a4  
    1616import org.axdt.as3.imp.parser.SymbolTable; 
    1717import org.axdt.as3.imp.parser.Ast.ASTNode; 
    18 import org.axdt.as3.imp.parser.Ast.IAnnotatableDirective_full; 
     18import org.axdt.as3.imp.parser.Ast.IAnnotatableDirective; 
    1919import org.axdt.as3.imp.parser.Ast.IName; 
    2020import org.axdt.as3.imp.parser.Ast.ImportDirective; 
     
    143143                ancestors = new ArrayList<IAst>(); 
    144144                for (IAst n = node; n != null; n = n.getParent()) { 
    145                         if (n instanceof IAnnotatableDirective_full 
     145                        if (n instanceof IAnnotatableDirective 
    146146                         || n instanceof ImportDirective 
    147147                         || n instanceof PackageDefinition 
  • org.axdt.as3/src/org/axdt/as3/imp/services/AS3FoldingUpdater.java

    r49cbb50 rb32f7a4  
    1414import org.axdt.as3.imp.parser.Ast.Block; 
    1515import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 
    16 import org.axdt.as3.imp.parser.Ast.ImportDirectiveList; 
     16import org.axdt.as3.imp.parser.Ast.ImportDirectives; 
    1717import org.axdt.as3.imp.parser.Ast.InterfaceBlock; 
    1818import org.axdt.as3.imp.parser.Ast.PackageDefinition; 
     
    147147                } 
    148148 
    149                 public boolean visit(ImportDirectiveList n) { 
     149                public boolean visit(ImportDirectives n) { 
    150150                        makeAnnotation(n); 
    151151                        if (foldImports) autoFoldLast(); 
  • org.axdt.as3/src/org/axdt/as3/imp/services/AS3LabelProvider.java

    r49cbb50 rb32f7a4  
    1414import lpg.runtime.IAst; 
    1515 
     16import org.axdt.as3.AS3Plugin; 
     17import org.axdt.as3.IAS3Resources; 
     18import org.axdt.as3.imp.parser.Ast.ASTNode; 
     19import org.axdt.as3.imp.parser.Ast.Attributes; 
     20import org.axdt.as3.imp.parser.Ast.ClassDefinition; 
     21import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 
     22import org.axdt.as3.imp.parser.Ast.IName; 
     23import org.axdt.as3.imp.parser.Ast.ImportDirective; 
     24import org.axdt.as3.imp.parser.Ast.ImportDirectives; 
     25import org.axdt.as3.imp.parser.Ast.InterfaceDefinition; 
     26import org.axdt.as3.imp.parser.Ast.PackageDefinition; 
     27import org.axdt.as3.imp.parser.Ast.VariableBinding; 
     28import org.axdt.as3.imp.parser.Ast.VariableDefinition; 
    1629import org.eclipse.core.resources.IFile; 
    1730import org.eclipse.core.resources.IMarker; 
     
    1932import org.eclipse.imp.editor.ModelTreeNode; 
    2033import org.eclipse.imp.services.ILabelProvider; 
    21 import org.axdt.as3.AS3Plugin; 
    22 import org.axdt.as3.IAS3Resources; 
    2334import org.eclipse.imp.utils.MarkerUtils; 
    2435import org.eclipse.jface.resource.ImageRegistry; 
    2536import org.eclipse.jface.viewers.ILabelProviderListener; 
    2637import org.eclipse.swt.graphics.Image; 
    27  
    28 import org.axdt.as3.imp.parser.Ast.*; 
    2938 
    3039public class AS3LabelProvider implements ILabelProvider { 
     
    9099                        IAst parent = ((VariableBinding) n).getParent().getParent(); 
    91100                        if (parent instanceof VariableDefinition) { 
    92                                 AttributeList attributes = ((VariableDefinition)parent).getAttributes(); 
     101                                Attributes attributes = ((VariableDefinition)parent).getAttributes(); 
    93102                                if (attributes != null) { 
    94103                                        for (Object attri:attributes.getArrayList()) { 
     
    102111                } else if (result.equals(OUTLINE_PUBLIC_METHOD_IMAGE)) { 
    103112                        FunctionDefinition method = (FunctionDefinition) n; 
    104                         AttributeList attributes = method.getAttributes(); 
     113                        Attributes attributes = method.getAttributes(); 
    105114                        if (attributes != null) { 
    106115                                for (Object attri:attributes.getArrayList()) { 
     
    131140                        return name != null ? name.toString() : "<default package>"; 
    132141                } 
    133                 if (n instanceof ImportDirectiveList) return "imports"; 
     142                if (n instanceof ImportDirectives) return "imports"; 
    134143                if (n instanceof ImportDirective) return ((ImportDirective) n).getName().toString(); 
    135144                if (n instanceof VariableBinding) return ((VariableBinding) n).getIdent().toString(); 
     
    165174                if (PackageDefinition.class.isAssignableFrom(nodeClass)) return OUTLINE_PACKAGE_IMAGE; 
    166175                if (ImportDirective.class.isAssignableFrom(nodeClass)) return OUTLINE_IMPORT_IMAGE; 
    167                 if (ImportDirectiveList.class.isAssignableFrom(nodeClass)) return OUTLINE_IMPORT_LIST_IMAGE; 
     176                if (ImportDirectives.class.isAssignableFrom(nodeClass)) return OUTLINE_IMPORT_LIST_IMAGE; 
    168177                if (ClassDefinition.class.isAssignableFrom(nodeClass)) return OUTLINE_CLASS_IMAGE; 
    169178                if (InterfaceDefinition.class.isAssignableFrom(nodeClass)) return OUTLINE_INTERFACE_IMAGE; 
  • org.axdt.as3/src/org/axdt/as3/imp/services/AS3ReferenceResolver.java

    r25b5d22 rb32f7a4  
    44 
    55import org.axdt.as3.imp.parser.AS3ParseController; 
    6 import org.axdt.as3.imp.parser.AS3Parser; 
    76import org.axdt.as3.imp.parser.SymbolTable; 
    87import org.axdt.as3.imp.parser.Ast.Ident; 
     
    109import org.eclipse.imp.language.ILanguageService; 
    1110import org.eclipse.imp.parser.IParseController; 
    12 import org.eclipse.imp.parser.SimpleLPGParseController; 
    1311import org.eclipse.imp.services.IReferenceResolver; 
    1412 
  • org.axdt.as3/src/org/axdt/as3/imp/services/AS3TokenColorer.java

    r49cbb50 rb32f7a4  
    11package org.axdt.as3.imp.services; 
    22 
     3import lpg.runtime.Adjunct; 
     4import lpg.runtime.IToken; 
     5 
     6import org.axdt.as3.imp.parser.AS3ParseController; 
     7import org.axdt.as3.imp.parser.AS3Parsersym; 
    38import org.eclipse.imp.parser.IParseController; 
    49import org.eclipse.imp.services.ITokenColorer; 
     
    1015import org.eclipse.swt.widgets.Display; 
    1116 
    12 import org.axdt.as3.imp.parser.AS3ParseController; 
    13 import org.axdt.as3.imp.parser.AS3Parsersym; 
    14  
    15 import lpg.runtime.Adjunct; 
    16 import lpg.runtime.IToken; 
    17  
    1817public class AS3TokenColorer extends TokenColorerBase implements AS3Parsersym, ITokenColorer { 
    1918 
     
    2423        public TextAttribute getColoring(IParseController controller, Object o) { 
    2524                IToken token = (IToken) o; 
    26                 if (token.getKind() == TK_EOF_TOKEN) return null; 
    27  
    2825                switch (token.getKind()) { 
    2926                case TK_IDENTIFIER: 
  • org.axdt.as3/src/org/axdt/as3/imp/services/AS3TreeModelBuilder.java

    r49cbb50 rb32f7a4  
    11package org.axdt.as3.imp.services; 
    22 
     3import org.axdt.as3.imp.parser.Ast.ASTNode; 
     4import org.axdt.as3.imp.parser.Ast.AbstractVisitor; 
     5import org.axdt.as3.imp.parser.Ast.ClassDefinition; 
     6import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 
     7import org.axdt.as3.imp.parser.Ast.ImportDirective; 
     8import org.axdt.as3.imp.parser.Ast.ImportDirectives; 
     9import org.axdt.as3.imp.parser.Ast.InterfaceDefinition; 
     10import org.axdt.as3.imp.parser.Ast.PackageDefinition; 
     11import org.axdt.as3.imp.parser.Ast.VariableBinding; 
     12import org.axdt.as3.imp.parser.Ast.VariableDefinition; 
    313import org.eclipse.imp.services.base.TreeModelBuilderBase; 
    4  
    5 import org.axdt.as3.imp.parser.Ast.*; 
    614 
    715public class AS3TreeModelBuilder extends TreeModelBuilderBase { 
     
    4048 
    4149                @Override 
    42                 public boolean visit(ImportDirectiveList n) { 
     50                public boolean visit(ImportDirectives n) { 
    4351                        pushSubItem(n); 
    4452                        return true; 
     
    5159 
    5260                @Override 
    53                 public void endVisit(ImportDirectiveList n) { 
     61                public void endVisit(ImportDirectives n) { 
    5462                        popSubItem(); 
    5563                } 
  • org.axdt.as3/src/org/axdt/as3/util/AS3EditorHyperLink.java

    r25b5d22 rb32f7a4  
    33import org.axdt.as3.AS3Plugin; 
    44import org.eclipse.core.resources.IFile; 
    5 import org.eclipse.core.runtime.IPath; 
    6 import org.eclipse.core.runtime.Platform; 
    7 import org.eclipse.imp.editor.EditorUtility; 
    85import org.eclipse.imp.editor.UniversalEditor; 
    96import org.eclipse.jface.text.IRegion; 
     
    1310import org.eclipse.ui.PartInitException; 
    1411import org.eclipse.ui.PlatformUI; 
    15 import org.eclipse.ui.editors.text.EditorsUI; 
    16 import org.eclipse.ui.internal.EditorManager; 
    1712import org.eclipse.ui.part.FileEditorInput; 
    1813