I am attempting to construct a compiler for the golfing language
And the tokens are of the correct values:
[@-1,0:0='⟨',<163>,1:0]
[@-1,1:1='1',<170>,1:1]
[@-1,2:2='|',<154>,1:2]
[@-1,3:3='2',<170>,1:3]
[@-1,4:4='⟩',<164>,1:4]
[@-1,5:5='⟨',<163>,1:5]
[@-1,6:6='1',<170>,1:6]
[@-1,7:7='|',<154>,1:7]
[@-1,8:8='2',<170>,1:8]
[@-1,9:9='⟩',<164>,1:9]
CodePudding user response:
IntelliJ displays this:
And when I run:
VyxalLexer lexer = new VyxalLexer(CharStreams.fromString("⟨1|2⟩⟨1|2⟩"));
VyxalParser parser = new VyxalParser(new CommonTokenStream(lexer));
System.out.println(parser.file().toStringTree(parser));
the following is printed:
(file (program (literal (list ⟨ (program (literal (number (integer 1)))) | (program (literal (number (integer 2)))) ⟩)) (literal (list ⟨ (program (literal (number (integer 1)))) | (program (literal (number (integer 2)))) ⟩))) <EOF>)
Which is in sync with what IntelliJ displays.
I'm guessing you haven't recently generated new parser classes. Causing your own Java code to use older parser classes than the IntelliJ plugin is using.
CodePudding user response:
I have figured out the problem. For some reason ANTLR was not parsing the Unicode escapes properly. Changing them to the characters themselves fixed the problem. Although the tree is being built correctly, I still get a "mismatched input EOF" error. As it works, I'll mark this as solved, but if anyone knows how to fix the mismatched input annoyance, please do tell me.