kach / nearley

📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
https://nearley.js.org
MIT License
3.57k stars 231 forks source link

Is this language too ambiguous? #582

Open CarbonMan opened 3 years ago

CarbonMan commented 3 years ago

I would like to write a translator for a legacy system. I have started using moo as the lexer and that seems to be going well, but I am a bit concerned with the parsing side of things. If I have a legacy statement like;

REPLACE FieldName1 WITH eExpression1 [ADDITIVE] [, FieldName2 WITH eExpression2 [ADDITIVE]] ... [Scope] [FOR lExpression1] [WHILE lExpression2] [IN nWorkArea | cTableAlias] [NOOPTIMIZE]

So this might look like; REPLACE myField WITH 1, myOtherField WITH 2 FOR mField ==5 IN thisTable

Where each [option] is optional and some elements ( FieldName1 WITH eExpression1 ) may repeat many times. How would I parse that? There seems to be too many possible combinations.