lark icon indicating copy to clipboard operation
lark copied to clipboard

Push/pop Lexer input file state (for include processing)

Open gwr opened this issue 3 years ago • 0 comments
trafficstars

I'd like to be able to switch the input file just after the lexer sees "include filename". Ideally this should happen while parsing and building the parse tree. (Possibly a parsing hook for the include rule in the grammar?)

I found one example of switching input files here: https://gist.github.com/MegaIng/c6abba4d9be87473d8d586734f2b39c9 but it doesn't look like that updates state so that errors are shown with the correct file and line number information etc.

I'd appreciate any advice on a good way to do this. I've attached files showing an example of what I'm trying to do. (Take off the .txt extensions.). See the "import" and "include" directives.

Thanks!

echo.idl.txt idl.lark.txt run.py.txt

gwr avatar Aug 02 '22 04:08 gwr