The #include pragma with relative path does not work. With a grammar file containing
...
#include :: "secondary.ebnf"
and code to compile it
with open("/full/path/to/main.ebnf") as source:
psr = tatsu.compile(source.read())
I'm getting tatsu.exceptions.ParseError caused by No such file or directory '/short/path/secondary.ebnf'.
Absolute paths work, but relative paths do not - there was always at least one path component missing no matter what was the os.getcwd() when running the code.
The problem is that with this method of grammar compilation TatSu cannot know the path to the grammar file, yet it uses the
filenamesettings when deriving path to the included grammar. So as to make this approach work, it is necessary thatfilenameis provided to thecompilecall like