import java.util.ArrayList;\r
\r
public class ExpressionParser {\r
+ List<List<String>> references = new ArrayList<List<String>>();\r
+ \r
+ public List<List<String>> getReferences() {\r
+ return references;\r
+ }\r
}\r
PARSER_END(ExpressionParser)\r
\r
| <STRING>\r
| "false"\r
| "true"\r
- | LOOKAHEAD(2) name() function_call_args()\r
- | component_reference()\r
+ | LOOKAHEAD( name() "(" ) name() function_call_args()\r
+ | { List<String> reference = new ArrayList<String>(); } \r
+ component_reference(reference)\r
+ { references.add(reference); }\r
// | "(" output_expression_list() ")"\r
// | "[" expression_list() { ";" expression_list() } "]"\r
//| "{" function_arguments() "}"\r
<IDENT> ( "." name() )?\r
}\r
\r
-void component_reference() : {\r
+void component_reference(List<String> reference) : {\r
} {\r
//IDENT [ array_subscripts ] [ "." component_reference ]\r
- <IDENT> ( "." component_reference() )?\r
+ <IDENT> { reference.add(token.image); } \r
+ ( "." component_reference(reference) )?\r
}\r
\r
\r
package org.simantics.sysdyn.expressionParser;\r
\r
import java.io.StringReader;\r
+import java.util.List;\r
\r
public class TestExpressionParser {\r
\r
);\r
try {\r
parser.expr();\r
+ for(List<String> ref : parser.getReferences()) {\r
+ System.out.println(ref);\r
+ }\r
} catch (ParseException e) {\r
System.out.println("While parsing " + string + ":");\r
// TODO Auto-generated catch block\r