jzimmerman / langcc

langcc: A Next-Generation Compiler Compiler
https://langcc.io
Apache License 2.0
1.73k stars 58 forks source link

Improving CPS. #48

Closed modulovalue closed 1 year ago

modulovalue commented 1 year ago

Consider the following grammar (in grammophone syntax):

# The 'a' could be CPSd to make this grammar less inadequate.
S -> OPT1 a.

# The 'a' would be CPSd which would make this grammar less inadequate.
OPT1 -> OPT2 a.

OPT2 -> a.
OPT2 -> .

# CPSing both 'a's makes this grammar SLR(1), CPSing only the 'a' after 'OPT2' doesn't help much.

CPSing the OPT2, as the paper describes, because it is CPS-eligible, doesn't seem to help much with making the grammar adequate. Doing that and CPSing the a after OPT1 would make the grammar SLR(1).

This feels like an opportunity where the CPS approach can be improved, that is, maybe the CPS-eligibility definition could benefit from being loosened to include symbols that are not limited to fresh symbols created during the flattening procedure.

modulovalue commented 1 year ago

Because langcc appears to be abandoned, I'm going to close this issue.