I am implementing an existing scripting language in part as a toy project and in part so that I can write my own implementation of the program that uses the language. One of the issues I’m running into is that I have a few constructs that overlap in terms of specification but are more clear when used: This mostly works,
Tag: ply
competing regular expressions (race condition)
I’m trying to use python PLY (lex/yacc) to parse a language called ‘GRBL’. GRBL looks something like this: The ‘G’ Codes tell a machine to ‘go’ (or move) and the coordinates say where. LEX requires us to specify a unique regular expression for every possible ‘token’. So in this case I need a regex that will clearly define ‘G00’ and
How can I create an abstract syntax tree considering ‘|’? (Ply / Yacc)
Considering the following grammar: This is my code using ply: How am I supposed to build an AST with the expression if I can’t access the operators? I could separate the functions like p_expr_plus, but in this case, I would eliminate operator precedence. The docs are not so helpful, since I’m a beginner and can’t solve this problem. The best