Re: Preferring a shorter token match

2020-12-02 Thread Jeffrey Kegler
How many commands? One approach that I just thought of and have never tested is to have fixed length variables, prioritized versus the commands of that length. Off the top of my head: var2 ~ priority=>1 PA_command ~ 'PA' priority=>2 PR_command ~ 'PR' priority=>2 include a catch-all var for

Re: Preferring a shorter token match

2020-12-02 Thread Jeffrey Kegler
I'll first describe your immediate problem, then ask a couple Q's. The problem: Lexing is LATM -- *Longest* Acceptable Token Matching. The lexeme priority is a tie breaker, used when tokens are the same length. When your grammar fails, "PAx" is your longest token, and the only choice at length

Preferring a shorter token match

2020-12-02 Thread Dean S
Hello, I'm having trouble figuring out how to express my grammar and was hoping someone could help. I've tried rewriting various ways and looking for some options that might change behavior, but I haven't been able to figure it out. I have a language with variable assignment and simple