Describe the bug
I was trying to parse a lark file using the lark.lark file provided in the repo, and I realized it does not like:
function: "ABS"i | "ARCTAN"i | "CEIL"i | "COS"i | "ERRORF"i | "EXP"i | "FLOOR"i |\
"LOG"i | "LOG10"i | "MAPVAL"i | "MAX"i | "MIN"i | "MOD"i | "NORMAL"i
I understand it is not a biggie since lark is not bootstrapped,
To Reproduce
Get lark.lark
Save this dummy grammar to parse_me.lark
start: (function? _NL)* function?
_NL: /(\r?\n)+\s*/
function: "ABS"i | "ARCTAN"i | "CEIL"i | "COS"i | "ERRORF"i | "EXP"i | "FLOOR"i |\
"LOG"i | "LOG10"i | "MAPVAL"i | "MAX"i | "MIN"i | "MOD"i | "NORMAL"i
Then parse it using lark.lark
from lark import Lark
with open("lark.lark", "r") as f:
lark_grammar = f.read()
parser = Lark(lark_grammar)
with open("parse_me.lark", "r") as f:
problem = f.read()
parsed_problem = parser.parse(problem)
You will get
lark.exceptions.UnexpectedCharacters: No terminal matches '\' in the current parser context, at line 3 col 82
"COS"i | "ERRORF"i | "EXP"i | "FLOOR"i |\
^
Expected one of:
* LSQB
* TOKEN
* __ANON_0
* _VBAR
* RULE
* LPAR
* REGEXP
* _NL
* STRING
Finding and replacing backward slash followed by a new line with "", is my current workaround, but probably lark.lark file needs to be updated.
Describe the bug
I was trying to parse a lark file using the lark.lark file provided in the repo, and I realized it does not like:
I understand it is not a biggie since lark is not bootstrapped,
To Reproduce
Get lark.lark
Save this dummy grammar to
parse_me.larkThen parse it using lark.lark
You will get
Finding and replacing backward slash followed by a new line with "", is my current workaround, but probably
lark.larkfile needs to be updated.