Simplest way to deal with "import" statement in ANTLR4 -


i’m using antlr4 , have "import" statement inside grammar.

does antlr4 have option automatically open , parse input file instead of doing inside visitor (creating parser/lexer , visitor each "import" declaration) ?

"pretty" sure i've seen can't find anymore.

inside grammar :

importstatement : 'import' id ';' // here ? action (java code)                                   // prepend ast current ast ? 

inside input files :

import test; 

there no built-in functionality this, because every language requiring has own set of rules how needs done. in addition, can make parse operation whole project go o(n) o(n²) (i.e. parsing each file once, parsing whole project each file).

if language allows build correct parse tree prior resolving imports (e.g. doesn't have arbitrary #define statements can appear in imports), should glad aren't c/c++ , parse each file independently before resolving import statements.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -