TatSu
TatSu copied to clipboard
#include fails to look on same directory as source
With base.ebnf and full.ebnf in the same directory with:
#include :: base.ebnf
Will search for the include in the current or parent directory, and fail.
+1.
And I found another issue.
When #include are chained, the first #include must be written from the parent directory, but the next #include must be written with a relative path.
- src tree
$ tree python-paml/src
python-paml/src
└── paml
├── cli.py
└── lib
├── __init__.py
├── grammar
│ ├── json.ebnf
│ ├── paml.ebnf
│ └── yaml.ebnf
├── main.py
└── parser.py
- paml.ebnf
@@grammar :: PAML
@@whitespace :: //
@@parseinfo :: True
#include :: "python-paml/src/paml/lib/grammar/yaml.ebnf"
- yaml.ebnf
@@grammar :: YAML
@@whitespace :: //
@@parseinfo :: True
#include :: "json.ebnf"
- json.ebnf
@@grammar :: JSON
@@whitespace :: //
@@parseinfo :: True
start =
jsonvalue $
;
jsonobject =
'{' ws ','%{ ws jsonstring ws ':' ws jsonvalue ws }* '}'
;
jsonarray =
'[' ','%{ jsonvalue }* ']'
;
jsonvalue = ws jsonvalue_ ws;
jsonvalue_ =
| jsonfalse
| jsontrue
| jsonnull
| jsonobject
| jsonarray
| jsonnumber
| jsonstring
;
jsonnumber = jsonfloat | jsonint;
jsonint = /[0-9]+/ ;
jsonfloat = /[0-9]+\.[0-9]+/ ;
jsonstring = /"[^"]*"/ ;
jsontrue = /true/ ;
jsonfalse = /false/ ;
jsonnull = /null/ ;
ws = /[ \t\n\r]*/ ;