Skip to content
Advertisement

Tag: ply

Proper way to handle ambiguous tokens in PLY

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,

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

Advertisement