Skip to content

Tag: antlr4

Extraneous input ” expecting {‘ ‘, ‘} – Antlr4

I have a text file which am parsing through antlr4. Text format Grammar Rules I get this What am i doing wrong and how could i make these rules better? Answer Your example input get properly parsed if you start with the init rule: prints: which looks like this indented: My guess is that the error you’re getting is produced

ANTLR4 Return values from a function

Im making a programming language as a project at my University and I’ve run into a problem with adding a return statement in functions. This is my grammar: And here is the custom visitor To help with transferring data I have made classes to carry values and function data. The problem I have atm is when I make a function

Separate definitions of decimal number and word in ANTLR grammar

I’m working on defining a grammar in ANTLR4 which includes words and numbers separately. Numbers are described: and words are described: The simplified grammar below describes the addition between either a word or a letter (and needs to be defined recursively like this): The issue is that when I enter ‘d3’ into the parser, I get a returned instance of