Changeset b32f7a496c511e07158f0d0752addedc2b378328
- Timestamp:
- 06/28/09 23:36:50 (15 months ago)
- Children:
- 2aa064d78a2c1162da70e2413b7c386278a1473d
- Parents:
- 1567fcce2711ee19e98902f8ef734f1a7dd9731f
- git-author:
- mb0 <mb0@…> (06/14/09 23:10:19)
- git-committer:
- mb0 <mb0@…> (06/28/09 23:36:50)
- Files:
-
- 3 added
- 23 modified
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/BasicLexerTest.java (modified) (3 diffs)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/BasicParserTest.java (modified) (10 diffs)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/ExpressionTest.java (modified) (2 diffs)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/ParseUtil.java (modified) (2 diffs)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/RegexContextTest.java (modified) (4 diffs)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/TutorialParserTest.java (modified) (1 diff)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/VirtualSemiTest.java (modified) (1 diff)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/xml/BasicXmlTest.java (modified) (1 diff)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3LexHelper.java (added)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Lexer.gi (modified) (6 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3ParseController.java (modified) (1 diff)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Parser.g (modified) (32 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/HelperAst.java (added)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/LexerTemplate.ggg (added)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTableVisitor.java (modified) (3 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/regex/RegexAst.java (modified) (1 diff)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/regex/RegexParser.g (modified) (2 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/xml/XmlAst.java (modified) (1 diff)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/xml/XmlParser.g (modified) (2 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3ContentProposer.java (modified) (2 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3FoldingUpdater.java (modified) (2 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3LabelProvider.java (modified) (6 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3ReferenceResolver.java (modified) (2 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3TokenColorer.java (modified) (3 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3TreeModelBuilder.java (modified) (3 diffs)
-
org.axdt.as3/src/org/axdt/as3/util/AS3EditorHyperLink.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/BasicLexerTest.java
r5eb830a rb32f7a4 59 59 60 60 private void assertTokens(IPrsStream lex, int[] kinds) throws Exception { 61 assertEquals(2 + kinds.length, lex.getTokens().size());62 61 for (int i = 0; i < kinds.length; i++) { 63 62 IToken token = lex.getTokenAt(i + 1); … … 80 79 81 80 public void testXml() throws Exception { 81 assertTokens(lex("<x"), new int[] { TK_LT, TK_IDENTIFIER}); 82 82 assertToken(lex("<xml/>"), TK_Xml); 83 83 assertToken(lex("<{tag} {attr}={value}/>"), TK_Xml); … … 90 90 assertToken(lex("/"), TK_DIV); 91 91 assertToken(lex("/="), TK_DIV_ASSIGN); 92 assertTokens(lex("/b;"), new int[] { TK_DIV, TK_IDENTIFIER, TK_SEMI }); 92 93 assertTokens(lex("/=b;"), new int[] { TK_DIV_ASSIGN, TK_IDENTIFIER, 93 94 TK_SEMI }); 94 assertTokens(lex("/b;"), new int[] { TK_DIV, TK_IDENTIFIER, TK_SEMI });95 95 } 96 96 97 97 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); 100 99 assertTokens( 101 100 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 }); 105 103 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, 109 107 TK_IDENTIFIER, TK_LPAREN, TK_RPAREN, TK_SEMI }); 110 108 assertTokens( 111 109 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, 114 112 TK_RPAREN, TK_IDENTIFIER, TK_LPAREN, TK_RPAREN, TK_SEMI }); 115 113 } -
org.axdt.as3.test/src/org/axdt/as3/imp/parser/BasicParserTest.java
r82cecb8 rb32f7a4 1 1 package org.axdt.as3.imp.parser; 2 3 import java.util.ArrayList; 2 4 3 5 import junit.framework.TestCase; … … 10 12 import org.axdt.as3.imp.parser.Ast.FunctionExpression; 11 13 import org.axdt.as3.imp.parser.Ast.IDirective; 12 import org.axdt.as3.imp.parser.Ast.ImportDirective List;14 import org.axdt.as3.imp.parser.Ast.ImportDirectives; 13 15 import org.axdt.as3.imp.parser.Ast.InterfaceDefinition; 14 16 import org.axdt.as3.imp.parser.Ast.Name; … … 19 21 20 22 public class BasicParserTest extends TestCase { 23 private AS3Parser parser; 21 24 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 } 25 47 public void testPackage() throws Exception { 26 48 Program prog; … … 54 76 prog = parse("package P{} f();"); 55 77 assertEquals(1, prog.getPackages().size()); 56 assert Equals(1, prog.getDirectives().size());78 assertFirstDirective(prog,ExpressionStatement.class); 57 79 58 80 // bom works just as expected … … 67 89 prog = parse("package P{} package Q{} function f(){}"); 68 90 assertEquals(2, prog.getPackages().size()); 69 assert Equals(1, prog.getDirectives().size());91 assertFirstDirective(prog,FunctionDefinition.class); 70 92 71 93 System.out.print("expected"); … … 75 97 76 98 public void testNamespace() throws Exception { 77 Program prog;78 99 NamespaceDefinition dir; 79 100 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); 83 102 assertEquals("NS1", dir.getName().toString()); 84 103 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); 88 105 assertEquals("NS2", dir.getName().toString()); 89 106 assertEquals("NS1", dir.getAssignment().toString()); 90 107 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); 94 109 assertEquals("NS3", dir.getName().toString()); 95 110 assertEquals(StringLiteral.class, dir.getAssignment().getClass()); … … 98 113 99 114 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); 105 119 assertEquals(3, list.size()); 106 120 assertEquals("A", list.getImportDirectiveAt(0).getName().toString()); … … 112 126 113 127 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); 119 131 assertEquals(Name.class, type.getName().getClass()); 120 132 assertEquals(null, type.getBody().getDirectives()); 121 133 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); 125 135 assertEquals(Name.class, type.getName().getClass()); 126 136 assertEquals(null, type.getBody().getDirectives()); 127 137 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); 131 139 assertEquals(2, type.getBody().getDirectives().size()); 132 140 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); 136 143 } 137 144 138 145 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); 151 153 } 152 154 153 155 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); 162 160 assertEquals("f", def.getName().toString()); 163 161 assertEquals(2, def.getBlock().getDirectives().size()); … … 165 163 assertEquals(null, common.getResultType()); 166 164 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); 186 194 assertEquals(FunctionExpression.class, ((ExpressionStatement)directive).getExpression().getClass()); 187 195 } 188 196 189 197 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); 195 201 assertEquals("T", def.getName().toString()); 196 202 assertEquals(2, def.getBody().getDirectives().size()); … … 198 204 assertEquals(FunctionDefinition.class, def.getBody().getDirectives().getDirectiveAt(1).getClass()); 199 205 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); 205 210 } 206 211 -
org.axdt.as3.test/src/org/axdt/as3/imp/parser/ExpressionTest.java
r82cecb8 rb32f7a4 87 87 assertExpression(parse("get"),Ident.class); 88 88 assertExpression(parse("set"),Ident.class); 89 //assertExpression(parse("namespace"),Ident.class);89 assertExpression(parse("namespace"),Ident.class); 90 90 assertExpression(parse("include"),Ident.class); 91 91 assertExpression(parse("dynamic"),Ident.class); … … 166 166 assertExpression(parse("a>>>b>>>c"),ShiftExpression.class); 167 167 assertExpression(parse("a<b"),RelationalExpression.class); 168 assertExpression(parse("a<b"),RelationalExpression.class);169 168 assertExpression(parse("a>b"),RelationalExpression.class); 170 169 assertExpression(parse("a<=b"),RelationalExpression.class); -
org.axdt.as3.test/src/org/axdt/as3/imp/parser/ParseUtil.java
r5eb830a rb32f7a4 13 13 AS3Parser parser = new AS3Parser(); 14 14 parser.reset(lexer.getILexStream()); 15 lexer.lexer(null, parser .getIPrsStream());15 lexer.lexer(null, parser); 16 16 return parser.getIPrsStream(); 17 17 } 18 18 public static Program parse(String content) { 19 return parse(content, -1 , false);19 return parse(content, -1); 20 20 } 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) { 22 32 char[] charArray = content.toCharArray(); 23 33 AS3Lexer lexer = new AS3Lexer(); … … 25 35 AS3Parser parser = new AS3Parser(); 26 36 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; 32 39 } 33 40 } -
org.axdt.as3.test/src/org/axdt/as3/imp/parser/RegexContextTest.java
r5eb830a rb32f7a4 1 1 package org.axdt.as3.imp.parser; 2 2 3 4 import junit.framework.TestCase; 3 5 4 6 import org.axdt.as3.imp.parser.Ast.FunctionDefinition; … … 10 12 import org.axdt.as3.imp.parser.Ast.VariableInitialisation; 11 13 12 import junit.framework.TestCase;13 14 14 public class RegexContextTest extends TestCase { 15 15 private Program parse(String content) { 16 return ParseUtil.parse(content,0 ,false);16 return ParseUtil.parse(content,0); 17 17 } 18 18 … … 35 35 } 36 36 String longTest = "function f():int{\n" + 37 "\tvar r:Regex=/AXDT/gi; \n" +37 "\tvar r:Regex=/AXDT/gi; \n" + 38 38 "\tif(0<='AXDT'.search(r))\n" + 39 39 "\t\treturn 1337;\n" + … … 41 41 "}"; 42 42 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" + 45 46 "\t\treturn 1337;\n" + 46 47 "\t}return 0;\n" + 47 48 "}"; 48 49 public void testWithVSemi() throws Exception { 49 // i finally (after 3 h concentrated work) got to the cause of50 50 // 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 reason52 // because it is not easy to determine from the context53 // whether an insertion is acceptable54 // 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(";",""))); 57 57 } 58 58 } -
org.axdt.as3.test/src/org/axdt/as3/imp/parser/TutorialParserTest.java
re9006de rb32f7a4 1 1 package org.axdt.as3.imp.parser; 2 3 import junit.framework.TestCase; 2 4 3 5 import org.axdt.as3.imp.parser.Ast.ExpressionStatement; 4 6 import org.axdt.as3.imp.parser.Ast.IDirective; 5 7 import org.axdt.as3.imp.parser.Ast.Program; 6 7 import junit.framework.TestCase;8 8 9 9 public class TutorialParserTest extends TestCase { -
org.axdt.as3.test/src/org/axdt/as3/imp/parser/VirtualSemiTest.java
r82cecb8 rb32f7a4 7 7 public class VirtualSemiTest extends TestCase { 8 8 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); 11 11 } 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}")); 21 24 } 22 25 } -
org.axdt.as3.test/src/org/axdt/as3/imp/parser/xml/BasicXmlTest.java
r01bd3b5 rb32f7a4 27 27 System.out.print("expected"); 28 28 assertNull(parse("<= 6;")); 29 System.out.print("expected"); 30 assertNull(parse("<x")); 29 31 assertNotNull(parse("<xml></lmx>")); 30 32 -
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Lexer.gi
r69d1ca8 rb32f7a4 9 9 %options single-productions 10 10 %options package=org.axdt.as3.imp.parser 11 %options template=LexerTemplate F.gi11 %options template=LexerTemplate.ggg 12 12 %options filter=AS3KWLexer.gi 13 13 14 14 %Notice 15 /./*16 * (c) Martin Schnabel - mb0@mb0.org17 */18 ./15 /./* 16 * (c) Martin Schnabel - mb0@mb0.org 17 */ 18 ./ 19 19 %END 20 20 21 21 %Globals 22 22 /. 23 import java.util.ArrayList;24 23 import org.eclipse.imp.parser.ILexer; 25 import org.axdt.as3.imp.parser.xml.*;26 import org.axdt.as3.imp.parser.regex.*;27 24 ./ 28 25 %End … … 54 51 STRICT_NOT_EQUAL 55 52 DIV 56 DIV_RX57 53 DIV_ASSIGN 58 54 PLUS … … 171 167 172 168 %Start 173 NextInputElement 169 NextInputElement 174 170 %End 175 171 … … 212 208 WhiteSpace ::= 213 209 WhiteSpaceCharacter 214 | LineTerminator215 210 | WhiteSpace WhiteSpaceCharacter 216 | WhiteSpace LineTerminator 211 212 NewLines ::= 213 LineTerminator 214 | NewLines LineTerminator 217 215 218 216 NextInputElement ::= ByteOrderMark 219 217 /.$BeginAction 220 makeBom();218 make.bom(); 221 219 $EndAction./ 222 220 NextInputElement ::= WhiteSpace 223 221 /.$BeginAction 224 skipToken(); 222 make.whiteSpace(); 223 $EndAction./ 224 NextInputElement ::= NewLines 225 /.$BeginAction 226 make.newLines(); 225 227 $EndAction./ 226 228 NextInputElement ::= IdentifierOrKeyword 227 229 /.$BeginAction 228 checkForKeyWord();230 make.keyWord(); 229 231 $EndAction./ 230 232 NextInputElement ::= Punctuator 231 233 NextInputElement ::= NumericLiteral 232 234 /.$BeginAction 233 makeToken($_Number);235 make.token($_Number); 234 236 $EndAction./ 235 237 NextInputElement ::= StringLiteral 236 238 /.$BeginAction 237 makeToken($_String);239 make.token($_String); 238 240 $EndAction./ 239 241 NextInputElement ::= LineComment 240 242 /.$BeginAction 241 makeComment($_SlComment);243 make.comment($_SlComment); 242 244 $EndAction./ 243 245 NextInputElement ::= BlockComment 244 246 /.$BeginAction 245 makeComment($_MlComment);247 make.comment($_MlComment); 246 248 $EndAction./ 247 249 … … 393 395 Punctuator ::= '?' 394 396 /.$BeginJava 395 makeToken($_QUESTION);397 make.token($_QUESTION); 396 398 $EndJava./ 397 399 Punctuator ::= '(' 398 400 /.$BeginJava 399 makeToken($_LPAREN);401 make.token($_LPAREN); 400 402 $EndJava./ 401 403 Punctuator ::= ')' 402 404 /.$BeginJava 403 makeToken($_RPAREN);405 make.token($_RPAREN); 404 406 $EndJava./ 405 407 Punctuator ::= '[' 406 408 /.$BeginJava 407 makeToken($_LBRACK);409 make.token($_LBRACK); 408 410 $EndJava./ 409 411 Punctuator ::= ']' 410 412 /.$BeginJava 411 makeToken($_RBRACK);413 make.token($_RBRACK); 412 414 $EndJava./ 413 415 Punctuator ::= '{' 414 416 /.$BeginJava 415 makeToken($_LCURLY);417 make.token($_LCURLY); 416 418 $EndJava./ 417 419 Punctuator ::= '}' 418 420 /.$BeginJava 419 makeToken($_RCURLY);421 make.token($_RCURLY); 420 422 $EndJava./ 421 423 Punctuator ::= ':' ':' 422 424 /.$BeginJava 423 makeToken($_DBL_COLON);425 make.token($_DBL_COLON); 424 426 $EndJava./ 425 427 Punctuator ::= ':' 426 428 /.$BeginJava 427 makeToken($_COLON);429 make.token($_COLON); 428 430 $EndJava./ 429 431 Punctuator ::= ',' 430 432 /.$BeginJava 431 makeToken($_COMMA);433 make.token($_COMMA); 432 434 $EndJava./ 433 435 Punctuator ::= '=' 434 436 /.$BeginJava 435 makeToken($_ASSIGN);437 make.token($_ASSIGN); 436 438 $EndJava./ 437 439 Punctuator ::= '=' '=' 438 440 /.$BeginJava 439 makeToken($_EQUAL);441 make.token($_EQUAL); 440 442 $EndJava./ 441 443 Punctuator ::= '=' '=' '=' 442 444 /.$BeginJava 443 makeToken($_STRICT_EQUAL);445 make.token($_STRICT_EQUAL); 444 446 $EndJava./ 445 447 Punctuator ::= '!' 446 448 /.$BeginJava 447 makeToken($_LNOT);449 make.token($_LNOT); 448 450 $EndJava./ 449 451 Punctuator ::= '~' 450 452 /.$BeginJava 451 makeToken($_BNOT);453 make.token($_BNOT); 452 454 $EndJava./ 453 455 Punctuator ::= '!' '=' 454 456 /.$BeginJava 455 makeToken($_NOT_EQUAL);457 make.token($_NOT_EQUAL); 456 458 $EndJava./ 457 459 Punctuator ::= '!' '=' '=' 458 460 /.$BeginJava 459 makeToken($_STRICT_NOT_EQUAL);461 make.token($_STRICT_NOT_EQUAL); 460 462 $EndJava./ 461 463 Punctuator ::= '/' 462 464 /.$BeginJava 463 makeToken($_DIV);465 make.token($_DIV); 464 466 $EndJava./ 465 467 Punctuator ::= '/' '=' 466 468 /.$BeginJava 467 makeToken($_DIV_ASSIGN);469 make.token($_DIV_ASSIGN); 468 470 $EndJava./ 469 471 Punctuator ::= '+' 470 472 /.$BeginJava 471 makeToken($_PLUS);473 make.token($_PLUS); 472 474 $EndJava./ 473 475 Punctuator ::= '+' '=' 474 476 /.$BeginJava 475 makeToken($_PLUS_ASSIGN);477 make.token($_PLUS_ASSIGN); 476 478 $EndJava./ 477 479 Punctuator ::= '+' '+' 478 480 /.$BeginJava 479 makeToken($_INC);481 make.token($_INC); 480 482 $EndJava./ 481 483 Punctuator ::= '-' 482 484 /.$BeginJava 483 makeToken($_MINUS);485 make.token($_MINUS); 484 486 $EndJava./ 485 487 Punctuator ::= '-' '=' 486 488 /.$BeginJava 487 makeToken($_MINUS_ASSIGN);489 make.token($_MINUS_ASSIGN); 488 490 $EndJava./ 489 491 Punctuator ::= '-' '-' 490 492 /.$BeginJava 491 makeToken($_DEC);493 make.token($_DEC); 492 494 $EndJava./ 493 495 Punctuator ::= '*' 494 496 /.$BeginJava 495 makeToken($_STAR);497 make.token($_STAR); 496 498 $EndJava./ 497 499 Punctuator ::= '*' '=' 498 500 /.$BeginJava 499 makeToken($_STAR_ASSIGN);501 make.token($_STAR_ASSIGN); 500 502 $EndJava./ 501 503 Punctuator ::= '%' 502 504 /.$BeginJava 503 makeToken($_MOD);505 make.token($_MOD); 504 506 $EndJava./ 505 507 Punctuator ::= '%' '=' 506 508 /.$BeginJava 507 makeToken($_MOD_ASSIGN);509 make.token($_MOD_ASSIGN); 508 510 $EndJava./ 509 511 Punctuator ::= '>' '>' 510 512 /.$BeginJava 511 makeToken($_SR);513 make.token($_SR); 512 514 $EndJava./ 513 515 Punctuator ::= '>' '>' '=' 514 516 /.$BeginJava 515 makeToken($_SR_ASSIGN);517 make.token($_SR_ASSIGN); 516 518 $EndJava./ 517 519 Punctuator ::= '>' '>' '>' 518 520 /.$BeginJava 519 makeToken($_BSR);521 make.token($_BSR); 520 522 $EndJava./ 521 523 Punctuator ::= '>' '>' '>' '=' 522 524 /.$BeginJava 523 makeToken($_BSR_ASSIGN);525 make.token($_BSR_ASSIGN); 524 526 $EndJava./ 525 527 Punctuator ::= '>' '=' 526 528 /.$BeginJava 527 makeToken($_GE);529 make.token($_GE); 528 530 $EndJava./ 529 531 Punctuator ::= '>' 530 532 /.$BeginJava 531 makeToken($_GT);533 make.token($_GT); 532 534 $EndJava./ 533 535 Punctuator ::= '<' '<' 534 536 /.$BeginJava 535 makeToken($_SL);537 make.token($_SL); 536 538 $EndJava./ 537 539 Punctuator ::= '<' '<' '=' 538 540 /.$BeginJava 539 makeToken($_SL_ASSIGN);541 make.token($_SL_ASSIGN); 540 542 $EndJava./ 541 543 Punctuator ::= '<' '=' 542 544 /.$BeginJava 543 makeToken($_LE);545 make.token($_LE); 544 546 $EndJava./ 545 547 Punctuator ::= '<' 546 548 /.$BeginJava 547 makeToken($_LT);549 make.token($_LT); 548 550 $EndJava./ 549 551 Punctuator ::= '^' 550 552 /.$BeginJava 551 makeToken($_BXOR);553 make.token($_BXOR); 552 554 $EndJava./ 553 555 Punctuator ::= '^' '=' 554 556 /.$BeginJava 555 makeToken($_BXOR_ASSIGN);557 make.token($_BXOR_ASSIGN); 556 558 $EndJava./ 557 559 Punctuator ::= '^' '^' '=' 558 560 /.$BeginJava 559 makeToken($_LXOR_ASSIGN);561 make.token($_LXOR_ASSIGN); 560 562 $EndJava./ 561 563 Punctuator ::= '|' 562 564 /.$BeginJava 563 makeToken($_BOR);565 make.token($_BOR); 564 566 $EndJava./ 565 567 Punctuator ::= '|' '=' 566 568 /.$BeginJava 567 makeToken($_BOR_ASSIGN);569 make.token($_BOR_ASSIGN); 568 570 $EndJava./ 569 571 Punctuator ::= '|' '|' 570 572 /.$BeginJava 571 makeToken($_LOR);573 make.token($_LOR); 572 574 $EndJava./ 573 575 Punctuator ::= '|' '|' '=' 574 576 /.$BeginJava 575 makeToken($_LOR_ASSIGN);577 make.token($_LOR_ASSIGN); 576 578 $EndJava./ 577 579 Punctuator ::= '&' 578 580 /.$BeginJava 579 makeToken($_BAND);581 make.token($_BAND); 580 582 $EndJava./ 581 583 Punctuator ::= '&' '=' 582 584 /.$BeginJava 583 makeToken($_BAND_ASSIGN);585 make.token($_BAND_ASSIGN); 584 586 $EndJava./ 585 587 Punctuator ::= '&' '&' 586 588 /.$BeginJava 587 makeToken($_LAND);589 make.token($_LAND); 588 590 $EndJava./ 589 591 Punctuator ::= '&' '&' '=' 590 592 /.$BeginJava 591 makeToken($_LAND_ASSIGN);593 make.token($_LAND_ASSIGN); 592 594 $EndJava./ 593 595 Punctuator ::= '@' 594 596 /.$BeginJava 595 makeToken($_E4X_ATTRI);597 make.token($_E4X_ATTRI); 596 598 $EndJava./ 597 599 Punctuator ::= ';' 598 600 /.$BeginJava 599 makeToken($_SEMI);601 make.token($_SEMI); 600 602 $EndJava./ 601 603 Punctuator ::= '.' 602 604 /.$BeginJava 603 makeToken($_DOT);605 make.token($_DOT); 604 606 $EndJava./ 605 607 Punctuator ::= '.' '.' 606 608 /.$BeginJava 607 makeToken($_E4X_DESC);609 make.token($_E4X_DESC); 608 610 $EndJava./ 609 611 Punctuator ::= '.' '.' '.' 610 612 /.$BeginJava 611 makeToken($_REST);613 make.token($_REST); 612 614 $EndJava./ 613 615 %End … … 615 617 %Headers 616 618 /. 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 } 787 645 ./%End 788 646 %Include -
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3ParseController.java
r364575f rb32f7a4 102 102 103 103 // Lex the stream to produce the token stream 104 lexer.lexer(my_monitor, parser , true);104 lexer.lexer(my_monitor, parser); 105 105 // fCurrentAst might (probably will) be 106 106 // inconsistent wrt the lex stream now -
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Parser.g
r25b5d22 rb32f7a4 29 29 %End 30 30 31 %Ast 32 %End 33 31 34 %Terminals 32 -- List of terminals needed by this grammar33 as break case catch class const continue 34 default delete do else extends false finally for function35 if implements import in instanceof interface internal is36 new null package private protected public37 return super switch this throw --to38 true try typeof35 -- 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 39 42 use var void while with 40 -- 43 -- Soft keyword terminals 41 44 each get set namespace include 42 45 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 48 50 IDENTIFIER 49 51 String 50 52 Number 51 53 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 ::= '...' 115 91 %End 116 92 … … 123 99 124 100 %Rules 125 --no_line_break ::= NO_LINE_BREAK126 101 -- 14 Expressions 127 102 -- opt, W = B = {allowin, noin} 128 103 -- 14.1 Identifiers 129 104 Identifier$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 105 Identifier$Ident ::= final$Token 135 106 Identifier$Ident ::= dynamic$Token 136 107 Identifier$Ident ::= static$Token 137 Identifier$Ident ::= xml$Token108 Identifier$Ident ::= prototype$Token 138 109 Identifier$Ident ::= override$Token 139 Identifier$Ident ::= final$Token140 Identifier$Ident ::= prototype$Token141 110 Identifier$Ident ::= native$Token 142 111 /. … … 169 138 PrimaryExpression ::= Literal 170 139 PrimaryExpression ::= QualifiedIdentifier 171 --PrimaryExpression ::= ReservedNamespace --? 140 PrimaryExpression ::= ReservedNamespace 172 141 PrimaryExpression ::= ParenListExpression 173 142 PrimaryExpression ::= ArrayInitialiser … … 184 153 Literal$BooleanLiteral ::= true$Token 185 154 Literal$BooleanLiteral ::= false$Token 186 Literal$RegexLiteral ::= DIV_RX$RegularExpression$Token155 Literal$RegexLiteral ::= RegularExpression$Token 187 156 Literal$NullLiteral ::= null$Token 188 157 … … 210 179 ObjectInitialiser$ObjectInitialiser ::= LCURLY$ NonemptyFieldList$Fields RCURLY$ 211 180 ObjectInitialiser$ObjectInitialiser ::= LCURLY$ RCURLY$ 212 NonemptyFieldList$ $LiteralField ::= LiteralField213 NonemptyFieldList$ $LiteralField ::= LiteralField COMMA$ NonemptyFieldList181 NonemptyFieldList$NonemptyFieldList$LiteralField ::= LiteralField 182 NonemptyFieldList$NonemptyFieldList$LiteralField ::= LiteralField COMMA$ NonemptyFieldList 214 183 LiteralField ::= FieldName COLON$ AssignmentExpression_allowin$AssignmentExpression 215 184 FieldName$FieldName ::= NonAttributeQualifiedIdentifier … … 219 188 -- 14.7 Array initialiser 220 189 ArrayInitialiser ::= LBRACK$ ElementList RBRACK$ 221 ElementList$ $LiteralElement ::= %empty222 ElementList$ $LiteralElement ::= LiteralElement223 ElementList$ $LiteralElement ::= COMMA$ ElementList224 ElementList$ $LiteralElement ::= LiteralElement COMMA$ ElementList190 ElementList$ElementList$LiteralElement ::= %empty 191 ElementList$ElementList$LiteralElement ::= LiteralElement 192 ElementList$ElementList$LiteralElement ::= COMMA$ ElementList 193 ElementList$ElementList$LiteralElement ::= LiteralElement COMMA$ ElementList 225 194 LiteralElement ::= AssignmentExpression_noin 226 195 … … 231 200 232 201 --14.10 Postfix Expressions 233 PostfixExpression ::= FullPostfixExpression 234 PostfixExpression ::= ShortNewExpression 202 PostfixExpression ::= FullPostfixExpression | ShortNewExpression 235 203 236 204 FullPostfixExpression ::= PrimaryExpression … … 240 208 FullPostfixExpression$Invocation ::= FullPostfixExpression$Expression Arguments 241 209 FullPostfixExpression$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$210 FullPostfixExpression$PostIncrementExpression ::= PostfixExpression$Expression --NO_LINE_BREAK$ 211 INC$ 212 FullPostfixExpression$PostDecrementExpression ::= PostfixExpression$Expression --NO_LINE_BREAK$ 213 DEC$ 246 214 247 215 --14.11 New expressions … … 309 277 RelationalExpression_allowin$RelationalExpression 310 278 ::= RelationalExpression_allowin$Left 311 RelationalOp WithIn$Op ShiftExpression$Right279 RelationalOperator_allowin$Op ShiftExpression$Right 312 280 313 281 RelationalExpression_noin ::= ShiftExpression 314 282 RelationalExpression_noin$RelationalExpression 315 283 ::= RelationalExpression_noin$Left 316 RelationalOperator $Op ShiftExpression$Right317 318 RelationalOperator $RelationalOperator284 RelationalOperator_noin$Op ShiftExpression$Right 285 286 RelationalOperator_noin$RelationalOperator 319 287 ::= LT$Token 320 288 | GT$Token … … 324 292 | is$Token 325 293 | as$Token 326 327 RelationalOpWithIn ::= RelationalOperator 328 RelationalOpWithIn$RelationalOperator 329 ::= in$Token 294 RelationalOperator_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 330 303 331 304 -- 14.16.5 Equality expressions --B … … 460 433 -- 14.20 List expressions 461 434 --B 462 ListExpression_allowin$ $AssignmentExpression_allowin435 ListExpression_allowin$ListExpression$AssignmentExpression 463 436 ::= AssignmentExpression_allowin 464 437 | ListExpression_allowin COMMA$ AssignmentExpression_allowin 465 438 466 ListExpression_noin$ $AssignmentExpression_noin439 ListExpression_noin$ListExpression$AssignmentExpression 467 440 ::= AssignmentExpression_noin 468 441 | ListExpression_noin COMMA$ AssignmentExpression_noin … … 472 445 TypeExpression_noin ::= NonAssignmentExpression_noin 473 446 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 450 Statement_sif ::= Block 451 | IfStatement_sif 477 452 | SwitchStatement 478 | WhileStatement_ abbrev479 | ForStatement_ abbrev480 | WithStatement_ abbrev453 | WhileStatement_sif 454 | ForStatement_sif 455 | WithStatement_sif 481 456 | TryStatement 482 | LabeledStatement_ abbrev457 | LabeledStatement_sif 483 458 | DefaultXMLNamespaceStatement 484 | SuperStatement _abbrev485 | DoStatement _abbrev486 | ContinueStatement _abbrev487 | BreakStatement _abbrev488 | ReturnStatement _abbrev489 | ThrowStatement _abbrev490 | ExpressionStatement _abbrev459 | SuperStatement 460 | DoStatement 461 | ContinueStatement 462 | BreakStatement 463 | ReturnStatement 464 | ThrowStatement 465 | ExpressionStatement 491 466 492 467 Statement_nosif ::= Block … … 499 474 | LabeledStatement_nosif 500 475 | 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 525 483 526 484 --W 527 Substatement_ abbrev$Substatement485 Substatement_sif$Substatement 528 486 ::= 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 533 492 Substatement_nosif$Substatement 534 493 ::= EmptyStatment 535 494 | 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 499 Substatements$Substatements$Substatement ::= %empty 500 Substatements$Substatements$Substatement ::= Substatements Substatement_sif 501 502 -- no empty semicolon ! use virtual semi instead ! 503 -- virtual semi is inserted before RCURLY 504 Semicolon$ ::= SEMI$ | VirtualSemicolon$ 560 505 561 506 -- 15.1 Empty statement … … 565 510 --ExpressionStatement ::= ListExpression -- la ! function --allowin 566 511 --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$ 512 ExpressionStatement$ExpressionStatement 513 ::= AssignmentExpression_allowin$Expression Semicolon$ 573 514 574 515 -- 15.3 Super statement 575 516 --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$ 517 SuperStatement$SuperStatement ::= super$ Arguments Semicolon$ 579 518 580 519 -- 15.4 Block statement 581 Block$Block ::= LCURLY$ Directives$Heads Directive_abbrev$Tail RCURLY$ 582 Block$Block ::= LCURLY$ Directive_abbrev$Tail RCURLY$ 520 Block$Block ::= LCURLY$ Directives$Directives RCURLY$ 583 521 Block$Block ::= LCURLY$ RCURLY$ 584 522 /. … … 593 531 public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 594 532 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 }603 533 ./ 604 534 605 535 -- 15.5 Labeled statement 606 536 --W 607 LabeledStatement_ abbrev$LabeledStatement ::= Identifier$Label COLON$ Substatement_abbrev$Statement537 LabeledStatement_sif$LabeledStatement ::= Identifier$Label COLON$ Substatement_sif$Statement 608 538 LabeledStatement_nosif$LabeledStatement ::= Identifier$Label COLON$ Substatement_nosif$Statement 609 LabeledStatement_full$LabeledStatement ::= Identifier$Label COLON$ Substatement_full$Statement610 539 611 540 -- 15.6 Conditional statements 612 541 -- 15.6.1 If statement 613 IfStatement_ abbrev$IfStatement ::= if$ ParenListExpression$Condition Substatement_abbrev$IfStatement614 IfStatement_ abbrev$IfStatement ::= if$ ParenListExpression$Condition Substatement_nosif$IfStatement else$ Substatement_abbrev$ElseStatement542 IfStatement_sif$IfStatement ::= if$ ParenListExpression$Condition Substatement_sif$IfStatement 543 IfStatement_sif$IfStatement ::= if$ ParenListExpression$Condition Substatement_nosif$IfStatement else$ Substatement_sif$ElseStatement 615 544 616 545 IfStatement_nosif$IfStatement ::= if$ ParenListExpression$Condition Substatement_nosif$IfStatement else$ Substatement_nosif$ElseStatement 617 618 IfStatement_full$IfStatement ::= if$ ParenListExpression$Condition Substatement_full$IfStatement619 IfStatement_full$IfStatement ::= if$ ParenListExpression$Condition Substatement_nosif$IfStatement else Substatement_full$ElseStatement620 546 621 547 -- 15.6.2 Switch statement 622 548 SwitchStatement ::= 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 549 CaseElements$CaseElements$CaseElement ::= %empty 550 CaseElements$CaseElements$CaseElement ::= CaseElements CaseElement 551 628 552 -- W 629 CaseElement_abbrev ::= Directive_abbrev | CaseLabel 630 --CaseElement_nosif ::= Directive_nosif | CaseLabel 631 CaseElement_full ::= Directive | CaseLabel 553 CaseElement$CaseElement ::= Directive | CaseLabel 632 554 CaseLabel$CaseLabel ::= case$ ListExpression_allowin COLON$ 633 555 CaseLabel$CaseLabel ::= default$ COLON$ … … 635 557 -- 15.7 Iteration statements 636 558 -- 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$ 559 DoStatement$DoStatement ::= do$ Substatement_sif$Statement while$ ParenListExpression$Condition Semicolon$ 641 560 642 561 -- 15.7.2 While statement --W 643 WhileStatement_ abbrev$WhileStatement644 ::= while$ ParenListExpression$Condition Substatement_ abbrev$Statement562 WhileStatement_sif$WhileStatement 563 ::= while$ ParenListExpression$Condition Substatement_sif$Statement 645 564 WhileStatement_nosif$WhileStatement 646 565 ::= while$ ParenListExpression$Condition Substatement_nosif$Statement 647 WhileStatement_full$WhileStatement648 ::= while$ ParenListExpression$Condition Substatement_full$Statement649 566 650 567 -- 15.7.3 For statements 651 568 --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 569 ForStatement_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 657 573 ForStatement_nosif$ForStatement 658 574 ::= for$ LPAREN$ ForInitializer SEMI$ OptionalExpression SEMI$ OptionalExpression RPAREN$ Substatement_nosif 659 575 | 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 667 577 ForInitializer ::= %empty 668 578 ForInitializer ::= ListExpression_noin … … 676 586 677 587 -- 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$ 588 ContinueStatement$ContinueStatement 589 ::= continue$ Semicolon$ 590 | continue$ NO_LINE_BREAK$ Identifier$Label Semicolon$ 692 591 693 592 -- 15.9 Break statement 694 593 --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$ 594 BreakStatement$BreakStatement 595 ::= break$ Semicolon$ 596 | break$ NO_LINE_BREAK$ Identifier$Label Semicolon$ 708 597 709 598 -- 15.10 With statement 710 599 --W 711 WithStatement_ abbrev$WithStatement ::= with$ ParenListExpression Substatement_abbrev$Statement600 WithStatement_sif$WithStatement ::= with$ ParenListExpression Substatement_sif$Statement 712 601 WithStatement_nosif$WithStatement ::= with$ ParenListExpression Substatement_nosif$Statement 713 WithStatement_full$WithStatement ::= with$ ParenListExpression Substatement_full$Statement714 602 715 603 -- 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$ 604 ReturnStatement$ReturnStatement 605 ::= return$ Semicolon$ 606 | return$ NO_LINE_BREAK$ ListExpression_allowin Semicolon$ 730 607 731 608 -- 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$ 609 ThrowStatement$ThrowStatement 610 ::= throw$ NO_LINE_BREAK$ ListExpression_allowin Semicolon$ 742 611 743 612 -- 15.13 Try statement … … 746 615 CatchClausesOpt ::= CatchClauses 747 616 CatchClausesOpt ::= %empty 748 CatchClauses$ $CatchClause ::= CatchClause749 CatchClauses$ $CatchClause ::= CatchClauses CatchClause617 CatchClauses$CatchClauses$CatchClause ::= CatchClause 618 CatchClauses$CatchClauses$CatchClause ::= CatchClauses CatchClause 750 619 CatchClause ::= catch$ LPAREN$ PlainParameter RPAREN$ Block 751 620 752 621 -- 15.14 Default XML namespace statement 753 DefaultXMLNamespaceStatement ::= default$ --no_line_break$ 754 'xml'$ --no_line_break$ 622 DefaultXMLNamespaceStatement ::= default$ NO_LINE_BREAK$ xml$ NO_LINE_BREAK$ 755 623 namespace$ ASSIGN$ NonAssignmentExpression_allowin 756 624 757 625 -- 16 Directives --W 758 AnnotatedDirective_abbrev759 ::= Attributes --no_line_break$760 AnnotatableDirective_abbrev761 | AnnotatableDirective_abbrev762 Directive_abbrev ::= AnnotatedDirective_abbrev763 | EmptyStatment764 | IncludeDirective765 | ImportDirectives766 | UseDirective767 | Statement_abbrev768 769 626 AnnotatedDirective 770 ::= Attributes -- no_line_break$771 AnnotatableDirective_full772 | AnnotatableDirective _full627 ::= Attributes --NO_LINE_BREAK$ 628 AnnotatableDirective 629 | AnnotatableDirective 773 630 Directive ::= AnnotatedDirective 774 631 | EmptyStatment 775 632 | IncludeDirective 776 | ImportDirectives -- ignore we just want to group imports633 | ImportDirectives --@ignore we just want to group imports 777 634 | UseDirective 778 | Statement_ full635 | Statement_sif 779 636 780 637 --W 781 AnnotatableDirective _abbrev638 AnnotatableDirective 782 639 ::= FunctionDefinition 783 | VariableDefinition Semi_abbrev640 | VariableDefinition_allowin 784 641 | ClassDefinition 785 642 | InterfaceDefinition 786 643 | NamespaceDefinition 787 644 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 645 Directives$Directives$Directive ::= Directive 646 Directives$Directives$Directive ::= Directives Directive 803 647 804 648 -- 16.1 Attributes 805 Attributes$$Attribute ::= Attribute 806 Attributes$$Attribute ::= Attributes Attribute --AttributeCombination 807 808 --AttributeCombination$$Attribute ::= Attribute no_line_break$ Attributes 649 Attributes$Attributes$Attribute ::= Attribute 650 Attributes$Attributes$Attribute ::= Attributes --NO_LINE_BREAK$ 651 Attribute 809 652 810 653 Attribute ::= AttributeExpression … … 816 659 817 660 -- 16.2 Import directive 818 ImportDirective$ImportDirective ::= import$ Name DOT$ STAR$OnDemand Semicolon _abbrev$819 ImportDirective$ImportDirective ::= import$ Name Semicolon _abbrev$661 ImportDirective$ImportDirective ::= import$ Name DOT$ STAR$OnDemand Semicolon$ 662 ImportDirective$ImportDirective ::= import$ Name Semicolon$ 820 663 821 664 -- grouping 822 ImportDirectives$ $ImportDirective665 ImportDirectives$ImportDirectives$ImportDirective 823 666 ::= ImportDirective 824 667 | ImportDirectives ImportDirective 825 668 826 669 -- 16.3 Include directive 827 IncludeDirective ::= include$ --no_line_break$ 828 String Semicolon_abbrev$ 670 IncludeDirective ::= include$ NO_LINE_BREAK$ String Semicolon$ 829 671 830 672 -- 16.4 Use directive 831 UseDirective ::= use$ namespace$ ListExpression_allowin Semicolon _abbrev$673 UseDirective ::= use$ namespace$ ListExpression_allowin Semicolon$ 832 674 833 675 -- 17 Definitions 834 676 -- 17.1 Variable definition 835 677 --B 678 VariableDefinition_noin$VariableDefinition 679 ::= VariableDefinitionKind$Kind 680 VariableBindingList_noin$RawBindings 836 681 VariableDefinition_allowin$VariableDefinition 837 682 ::= VariableDefinitionKind$Kind 838 VariableBindingList_allowin$Bindings 839 VariableDefinition_noin$VariableDefinition 840 ::= VariableDefinitionKind$Kind 841 VariableBindingList_noin$Bindings 683 VariableBindingList_allowin$RawBindings 684 Semicolon$ 842 685 /. 843 public AttributeList getAttributes() { 686 public AbstractASTNodeList getBindings() { 687 return _RawBindings instanceof IVariableBindingList 688 ? (AbstractASTNodeList)_RawBindings : null; 689 } 690 public Attributes getAttributes() { 844 691 if (!(getParent() instanceof AnnotatedDirective)) return null; 845 692 return ((AnnotatedDirective) getParent()).getAttributes(); 846 693 } 847 694 ./ 695 848 696 VariableDefinitionKind$VarKind ::= var$Token 849 697 VariableDefinitionKind$ConstKind ::= const$Token 850 698 851 VariableDefinitionSemi_abbrev$VariableDefinition852 ::= VariableDefinitionKind$Kind853 VariableBindingList_allowin$Bindings854 Semicolon_abbrev$855 VariableDefinitionSemi_full$VariableDefinition856 ::= VariableDefinitionKind$Kind857 VariableBindingList_allowin$Bindings858 Semicolon_full$859 699 --VariableMods$$VariableMod ::= %empty 860 700 --VariableMods$$VariableMod ::= VariableMods VariableMod … … 864 704 865 705 --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 706 VariableBindingList_allowin$VariableBindingsAllowin$VariableBinding_allowin ::= VariableBinding_allowin 707 VariableBindingList_allowin$VariableBindingsAllowin$VariableBinding_allowin ::= VariableBindingList_allowin COMMA$ VariableBinding_allowin 708 709 VariableBindingList_noin$VariableBindingsNoin$VariableBinding_noin ::= VariableBinding_noin 710 VariableBindingList_noin$VariableBindingsNoin$VariableBinding_noin ::= VariableBindingList_noin COMMA$ VariableBinding_noin 711 712 VariableBindingList ::= VariableBindingList_allowin | VariableBindingList_noin 871 713 --B 872 714 VariableBinding_allowin$VariableBinding … … 874 716 VariableBinding_noin$VariableBinding 875 717 ::= TypedIdentifier_noin$Ident VariableInitialisation_noin$Initializer 718 876 719 --B 877 720 VariableInitialisation_allowin$VariableInitialisation … … 892 735 893 736 -- 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 737 FunctionDefinition$FunctionDefinition ::= function$ FunctionAccessor$Accessor Identifier$Name FunctionCommon$Common Block 897 738 /. 898 739 public boolean isConstructor; … … 900 741 public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 901 742 public SymbolTable getSymbolTable() { return symbolTable; } 902 public Attribute ListgetAttributes() {743 public Attributes getAttributes() { 903 744 if (!(getParent() instanceof AnnotatedDirective)) return null; 904 745 return ((AnnotatedDirective) getParent()).getAttributes(); 905 746 } 906 747 ./ 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 748 FunctionSignature$FunctionDefinition ::= function$ FunctionAccessor$Accessor Identifier$Name FunctionCommon$Common Semicolon$ 749 750 FunctionAccessor ::= %empty 751 FunctionAccessor$FunctionAccessor ::= get$Token NO_LINE_BREAK$ 752 FunctionAccessor$FunctionAccessor ::= set$Token NO_LINE_BREAK$ 913 753 914 754 --FunctionMods$$FunctionMod ::= %empty … … 930 770 931 771 -- 17.2.3 Parameter list 932 Parameters$ $Parameter ::= %empty933 Parameters$ $Parameter ::= NonemptyParameters934 NonemptyParameters$ $Parameter ::= Parameter935 NonemptyParameters$ $Parameter ::= PlainParameter COMMA$ NonemptyParameters772 Parameters$Parameters$Parameter ::= %empty 773 Parameters$Parameters$Parameter ::= NonemptyParameters 774 NonemptyParameters$Parameters$Parameter ::= Parameter 775 NonemptyParameters$Parameters$Parameter ::= PlainParameter COMMA$ NonemptyParameters 936 776 Parameter ::= PlainParameter | RestParameter 937 777 PlainParameter$PlainParameter ::= TypedIdentifier_allowin$Ident … … 953 793 public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 954 794 public SymbolTable getSymbolTable() { return symbolTable; } 955 public Attribute ListgetAttributes() {795 public Attributes getAttributes() { 956 796 if (!(getParent() instanceof AnnotatedDirective)) return null; 957 797 return ((AnnotatedDirective) getParent()).getAttributes(); … … 976 816 Inheritance$Inheritance ::= extends$ TypeExpression_allowin$Extends implements$ TypeExpressionList$Implements 977 817 978 TypeExpressionList$ $TypeExpression_allowin ::= TypeExpression_allowin979 TypeExpressionList$ $TypeExpression_allowin ::= TypeExpressionList COMMA$ TypeExpression_allowin818 TypeExpressionList$TypeExpressionList$TypeExpression_allowin ::= TypeExpression_allowin 819 TypeExpressionList$TypeExpressionList$TypeExpression_allowin ::= TypeExpressionList COMMA$ TypeExpression_allowin 980 820 981 821 -- 17.3.4 Class block … … 986 826 InterfaceDefinition ::= interface$ Name ExtendsList InterfaceBlock$Body 987 827 /. 988 public Attribute ListgetAttributes() {828 public Attributes getAttributes() { 989 829 if (!(getParent() instanceof AnnotatedDirective)) return null; 990 830 return ((AnnotatedDirective) getParent()).getAttributes(); … … 1007 847 public SymbolTable getSymbolTable() { return symbolTable; } 1008 848 ./ 1009 InterfaceDirectives$ $FunctionSignature ::= FunctionSignature1010 InterfaceDirectives$ $FunctionSignature ::= InterfaceDirectives FunctionSignature849 InterfaceDirectives$InterfaceDirectives$FunctionSignature ::= FunctionSignature 850 InterfaceDirectives$InterfaceDirectives$FunctionSignature ::= InterfaceDirectives FunctionSignature 1011 851 -- 17.5 Package definition 1012 852 PackageDefinition$PackageDefinition ::= package$ Block$Body … … 1020 860 NamespaceDefinition$NamespaceDefinition ::= namespace$ Identifier$Name ASSIGN$ AssignmentExpression_allowin$Assignment 1021 861 /. 1022 public Attribute ListgetAttributes() {862 public Attributes getAttributes() { 1023 863 if (!(getParent() instanceof AnnotatedDirective)) return null; 1024 864 return ((AnnotatedDirective) getParent()).getAttributes(); … … 1036 876 ./ 1037 877 1038 PackageDefinitions$$PackageDefinition ::= %empty 1039 PackageDefinitions$$PackageDefinition ::= PackageDefinitions PackageDefinition 878 PackageDefinitions$PackageDefinitions$PackageDefinition ::= %empty 879 PackageDefinitions$PackageDefinitions$PackageDefinition ::= PackageDefinitions PackageDefinition 880 881 882 -- unused terminal to group types 883 VariableDefinition ::= VariableDefinition_allowin | VariableDefinition_noin 884 VariableBinding ::= VariableBinding_allowin | VariableBinding_noin 885 Statement ::= Statement_sif | Statement_nosif 886 Substatement ::= Substatement_sif | Substatement_nosif 887 AssignmentExpression ::= AssignmentExpression_allowin | AssignmentExpression_noin 1040 888 %End 1041 889 … … 1046 894 1047 895 %Types 896 List ::= TypeExpressionList 897 1048 898 RelationalExpression ::= RelationalExpression_allowin | RelationalExpression_noin 1049 899 … … 1066 916 AssignmentExpression ::= AssignmentExpression_allowin | AssignmentExpression_noin 1067 917 1068 --AssignmentExpressionList ::= AssignmentExpression_allowinList | AssignmentExpression_noinList1069 1070 918 TypeExpression ::= TypeExpression_allowin | TypeExpression_noin 1071 919 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 920 Statement ::= Statement_sif | Statement_nosif 921 922 Substatement ::= Substatement_sif | Substatement_nosif 923 924 ExpressionStatement ::= ExpressionStatement_sif | ExpressionStatement_nosif 925 926 LabeledStatement ::= LabeledStatement_sif | LabeledStatement_nosif 927 928 IfStatement ::= IfStatement_sif | IfStatement_nosif 929 930 WhileStatement ::= WhileStatement_sif | WhileStatement_nosif 931 932 ForStatement ::= ForStatement_sif | ForStatement_nosif 933 934 WithStatement ::= WithStatement_sif | WithStatement_nosif 1103 935 %End -
org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTableVisitor.java
r25b5d22 rb32f7a4 7 7 8 8 import org.axdt.as3.imp.parser.Ast.AssignmentExpression; 9 import org.axdt.as3.imp.parser.Ast.Attribute List;9 import org.axdt.as3.imp.parser.Ast.Attributes; 10 10 import org.axdt.as3.imp.parser.Ast.Block; 11 11 import org.axdt.as3.imp.parser.Ast.ClassDefinition; … … 91 91 name = n.getAccessor().toString() + " " + name; 92 92 } 93 Attribute Listattributes = n.getAttributes();93 Attributes attributes = n.getAttributes(); 94 94 if (attributes != null) { 95 95 for (Object o:n.getAttributes().getArrayList()) { … … 152 152 if (parent instanceof VariableDefinition) { 153 153 VariableDefinition f = (VariableDefinition) parent; 154 Attribute Listattributes = f.getAttributes();154 Attributes attributes = f.getAttributes(); 155 155 if (attributes != null) { 156 156 for (Object o:f.getAttributes().getArrayList()) { -
org.axdt.as3/src/org/axdt/as3/imp/parser/regex/RegexAst.java
re9006de rb32f7a4 1 1 package org.axdt.as3.imp.parser.regex; 2 2 3 public class RegexAst { 3 import org.axdt.as3.imp.parser.HelperAst; 4 4 5 public final int start; 6 public final int end; 5 public class RegexAst extends HelperAst { 7 6 8 7 public RegexAst(RegexAst ast) { 9 this.start = ast.start; 10 this.end = ast.end; 8 super(ast); 11 9 } 12 10 13 11 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); 33 13 } 34 14 } -
org.axdt.as3/src/org/axdt/as3/imp/parser/regex/RegexParser.g
ra106cc3 rb32f7a4 12 12 %options single_productions 13 13 %options package=org.axdt.as3.imp.parser.regex 14 %options template=LexerTemplate F.gi14 %options template=LexerTemplate.ggg 15 15 %options ast_type=RegexAst 16 16 … … 188 188 return result; 189 189 } 190 public void reset( LpgLexStream stream) {190 public void reset(lpg.runtime.LexStream stream) { 191 191 reset(stream.getInputChars(),stream.getFileName(),stream.getTab()); 192 192 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 1 1 package org.axdt.as3.imp.parser.xml; 2 2 3 public class XmlAst { 3 import org.axdt.as3.imp.parser.HelperAst; 4 4 5 public final int start; 6 public final int end; 5 public class XmlAst extends HelperAst { 7 6 8 7 public XmlAst(XmlAst ast) { 9 this.start = ast.start; 10 this.end = ast.end; 8 super(ast); 11 9 } 12 10 13 11 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); 33 13 } 34 14 } -
org.axdt.as3/src/org/axdt/as3/imp/parser/xml/XmlParser.g
ra106cc3 rb32f7a4 11 11 %options single_productions 12 12 %options package=org.axdt.as3.imp.parser.xml 13 %options template=LexerTemplate F.gi13 %options template=LexerTemplate.ggg 14 14 %options ast_type=XmlAst 15 15 … … 312 312 return result; 313 313 } 314 public void reset( LpgLexStream stream) {314 public void reset(lpg.runtime.LexStream stream) { 315 315 reset(stream.getInputChars(),stream.getFileName(),stream.getTab()); 316 316 lexStream.setMessageHandler(org.axdt.as3.imp.parser.AS3MessageHandler.NULL_MESSAGE_HANDLER); -
org.axdt.as3/src/org/axdt/as3/imp/services/AS3ContentProposer.java
r1567fcc rb32f7a4 16 16 import org.axdt.as3.imp.parser.SymbolTable; 17 17 import org.axdt.as3.imp.parser.Ast.ASTNode; 18 import org.axdt.as3.imp.parser.Ast.IAnnotatableDirective _full;18 import org.axdt.as3.imp.parser.Ast.IAnnotatableDirective; 19 19 import org.axdt.as3.imp.parser.Ast.IName; 20 20 import org.axdt.as3.imp.parser.Ast.ImportDirective; … … 143 143 ancestors = new ArrayList<IAst>(); 144 144 for (IAst n = node; n != null; n = n.getParent()) { 145 if (n instanceof IAnnotatableDirective _full145 if (n instanceof IAnnotatableDirective 146 146 || n instanceof ImportDirective 147 147 || n instanceof PackageDefinition -
org.axdt.as3/src/org/axdt/as3/imp/services/AS3FoldingUpdater.java
r49cbb50 rb32f7a4 14 14 import org.axdt.as3.imp.parser.Ast.Block; 15 15 import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 16 import org.axdt.as3.imp.parser.Ast.ImportDirective List;16 import org.axdt.as3.imp.parser.Ast.ImportDirectives; 17 17 import org.axdt.as3.imp.parser.Ast.InterfaceBlock; 18 18 import org.axdt.as3.imp.parser.Ast.PackageDefinition; … … 147 147 } 148 148 149 public boolean visit(ImportDirective Listn) {149 public boolean visit(ImportDirectives n) { 150 150 makeAnnotation(n); 151 151 if (foldImports) autoFoldLast(); -
org.axdt.as3/src/org/axdt/as3/imp/services/AS3LabelProvider.java
r49cbb50 rb32f7a4 14 14 import lpg.runtime.IAst; 15 15 16 import org.axdt.as3.AS3Plugin; 17 import org.axdt.as3.IAS3Resources; 18 import org.axdt.as3.imp.parser.Ast.ASTNode; 19 import org.axdt.as3.imp.parser.Ast.Attributes; 20 import org.axdt.as3.imp.parser.Ast.ClassDefinition; 21 import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 22 import org.axdt.as3.imp.parser.Ast.IName; 23 import org.axdt.as3.imp.parser.Ast.ImportDirective; 24 import org.axdt.as3.imp.parser.Ast.ImportDirectives; 25 import org.axdt.as3.imp.parser.Ast.InterfaceDefinition; 26 import org.axdt.as3.imp.parser.Ast.PackageDefinition; 27 import org.axdt.as3.imp.parser.Ast.VariableBinding; 28 import org.axdt.as3.imp.parser.Ast.VariableDefinition; 16 29 import org.eclipse.core.resources.IFile; 17 30 import org.eclipse.core.resources.IMarker; … … 19 32 import org.eclipse.imp.editor.ModelTreeNode; 20 33 import org.eclipse.imp.services.ILabelProvider; 21 import org.axdt.as3.AS3Plugin;22 import org.axdt.as3.IAS3Resources;23 34 import org.eclipse.imp.utils.MarkerUtils; 24 35 import org.eclipse.jface.resource.ImageRegistry; 25 36 import org.eclipse.jface.viewers.ILabelProviderListener; 26 37 import org.eclipse.swt.graphics.Image; 27 28 import org.axdt.as3.imp.parser.Ast.*;29 38 30 39 public class AS3LabelProvider implements ILabelProvider { … … 90 99 IAst parent = ((VariableBinding) n).getParent().getParent(); 91 100 if (parent instanceof VariableDefinition) { 92 Attribute Listattributes = ((VariableDefinition)parent).getAttributes();101 Attributes attributes = ((VariableDefinition)parent).getAttributes(); 93 102 if (attributes != null) { 94 103 for (Object attri:attributes.getArrayList()) { … … 102 111 } else if (result.equals(OUTLINE_PUBLIC_METHOD_IMAGE)) { 103 112 FunctionDefinition method = (FunctionDefinition) n; 104 Attribute Listattributes = method.getAttributes();113 Attributes attributes = method.getAttributes(); 105 114 if (attributes != null) { 106 115 for (Object attri:attributes.getArrayList()) { … … 131 140 return name != null ? name.toString() : "<default package>"; 132 141 } 133 if (n instanceof ImportDirective List) return "imports";142 if (n instanceof ImportDirectives) return "imports"; 134 143 if (n instanceof ImportDirective) return ((ImportDirective) n).getName().toString(); 135 144 if (n instanceof VariableBinding) return ((VariableBinding) n).getIdent().toString(); … … 165 174 if (PackageDefinition.class.isAssignableFrom(nodeClass)) return OUTLINE_PACKAGE_IMAGE; 166 175 if (ImportDirective.class.isAssignableFrom(nodeClass)) return OUTLINE_IMPORT_IMAGE; 167 if (ImportDirective List.class.isAssignableFrom(nodeClass)) return OUTLINE_IMPORT_LIST_IMAGE;176 if (ImportDirectives.class.isAssignableFrom(nodeClass)) return OUTLINE_IMPORT_LIST_IMAGE; 168 177 if (ClassDefinition.class.isAssignableFrom(nodeClass)) return OUTLINE_CLASS_IMAGE; 169 178 if (InterfaceDefinition.class.isAssignableFrom(nodeClass)) return OUTLINE_INTERFACE_IMAGE; -
org.axdt.as3/src/org/axdt/as3/imp/services/AS3ReferenceResolver.java
r25b5d22 rb32f7a4 4 4 5 5 import org.axdt.as3.imp.parser.AS3ParseController; 6 import org.axdt.as3.imp.parser.AS3Parser;7 6 import org.axdt.as3.imp.parser.SymbolTable; 8 7 import org.axdt.as3.imp.parser.Ast.Ident; … … 10 9 import org.eclipse.imp.language.ILanguageService; 11 10 import org.eclipse.imp.parser.IParseController; 12 import org.eclipse.imp.parser.SimpleLPGParseController;13 11 import org.eclipse.imp.services.IReferenceResolver; 14 12 -
org.axdt.as3/src/org/axdt/as3/imp/services/AS3TokenColorer.java
r49cbb50 rb32f7a4 1 1 package org.axdt.as3.imp.services; 2 2 3 import lpg.runtime.Adjunct; 4 import lpg.runtime.IToken; 5 6 import org.axdt.as3.imp.parser.AS3ParseController; 7 import org.axdt.as3.imp.parser.AS3Parsersym; 3 8 import org.eclipse.imp.parser.IParseController; 4 9 import org.eclipse.imp.services.ITokenColorer; … … 10 15 import org.eclipse.swt.widgets.Display; 11 16 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 18 17 public class AS3TokenColorer extends TokenColorerBase implements AS3Parsersym, ITokenColorer { 19 18 … … 24 23 public TextAttribute getColoring(IParseController controller, Object o) { 25 24 IToken token = (IToken) o; 26 if (token.getKind() == TK_EOF_TOKEN) return null;27 28 25 switch (token.getKind()) { 29 26 case TK_IDENTIFIER: -
org.axdt.as3/src/org/axdt/as3/imp/services/AS3TreeModelBuilder.java
r49cbb50 rb32f7a4 1 1 package org.axdt.as3.imp.services; 2 2 3 import org.axdt.as3.imp.parser.Ast.ASTNode; 4 import org.axdt.as3.imp.parser.Ast.AbstractVisitor; 5 import org.axdt.as3.imp.parser.Ast.ClassDefinition; 6 import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 7 import org.axdt.as3.imp.parser.Ast.ImportDirective; 8 import org.axdt.as3.imp.parser.Ast.ImportDirectives; 9 import org.axdt.as3.imp.parser.Ast.InterfaceDefinition; 10 import org.axdt.as3.imp.parser.Ast.PackageDefinition; 11 import org.axdt.as3.imp.parser.Ast.VariableBinding; 12 import org.axdt.as3.imp.parser.Ast.VariableDefinition; 3 13 import org.eclipse.imp.services.base.TreeModelBuilderBase; 4 5 import org.axdt.as3.imp.parser.Ast.*;6 14 7 15 public class AS3TreeModelBuilder extends TreeModelBuilderBase { … … 40 48 41 49 @Override 42 public boolean visit(ImportDirective Listn) {50 public boolean visit(ImportDirectives n) { 43 51 pushSubItem(n); 44 52 return true; … … 51 59 52 60 @Override 53 public void endVisit(ImportDirective Listn) {61 public void endVisit(ImportDirectives n) { 54 62 popSubItem(); 55 63 } -
org.axdt.as3/src/org/axdt/as3/util/AS3EditorHyperLink.java
r25b5d22 rb32f7a4 3 3 import org.axdt.as3.AS3Plugin; 4 4 import 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;8 5 import org.eclipse.imp.editor.UniversalEditor; 9 6 import org.eclipse.jface.text.IRegion; … … 13 10 import org.eclipse.ui.PartInitException; 14 11 import org.eclipse.ui.PlatformUI; 15 import org.eclipse.ui.editors.text.EditorsUI;16 import org.eclipse.ui.internal.EditorManager;17 12 import org.eclipse.ui.part.FileEditorInput; 18 13
