Replies: 3 comments 11 replies
-
You need to look at what token type is actually being matched; no doubt there is a duplicate rule to match it important |
Beta Was this translation helpful? Give feedback.
-
sure. First i suggest using the ANTLR plugin in intellij. Next you likely have a rule set in this order:
Then the parser will look for IMPORT but see ID. |
Beta Was this translation helpful? Give feedback.
-
as far as I understand, first you need to list complete matches in the lexical rules. Symbols and keywords. then we write lexical rules like ID. I tried to make ID a parser rule, but still the problem persists. in the plugin, everything is parsed normally (the tree is normally built), and when the program starts, the result is different. |
Beta Was this translation helpful? Give feedback.
-
hello, i get error:mismatched input 'import' expecting 'import'.
i use this code: CharStream stream = CharStreams.fromFileName("./test", StandardCharsets.US_ASCII);
langosLexer lexer = new langosLexer(stream);
CommonTokenStream tokens = new CommonTokenStream(lexer);
langosWithoutSyntaxParser parser = new langosWithoutSyntaxParser(tokens);
MylangosWithoutSyntaxVisitor visitor = new MylangosWithoutSyntaxVisitor();
System.out.print(visitor.visitEntry_point(parser.entry_point()));
//https://github.com/lexasub/langA/blob/master/src/org/lexasub/langosThirdTryWithoutPromise/IO.java
my grammatic:
https://github.com/lexasub/langA/blob/master/langosWithoutSyntax.g4
Beta Was this translation helpful? Give feedback.
All reactions