3 ms·
Looks good, but I'm sceptical that I can specify perl5 or raku with it, as this would need dynamic flex rules. python, php or ruby should be fine though.
by rurban 4y ago
Looks good, but I'm sceptical that I can specify perl5 or raku with it, as this would need dynamic flex rules.
python, php or ruby should be fine though.
- KerrAvon 4y agoIt includes a grammar for Python but says it has some limitations, so maybe, sort of. Amusingly, the included C grammar is shorter than the Python grammar. Ruby has some syntactical edge cases that make parsing a bit tricky.
- defen 4y agoThe C grammar is also not complete, so it doesn't necessarily mean anything that it's shorter than the Python one.
- jzimmerman64 4y agoCorrect. The C/C++ grammar is not complete; it only encodes the subset of the language that was needed to bootstrap langcc itself. As far as I am aware, however, the Python grammar parses the full industrial language Python 3.9.12.
- defen 4y agoDo you think it would be possible to use this tool to create a full C frontend (including preprocessor)? I imagine the difficult part would be passing preprocessed text (including generated source e.g. pasted tokens, and expansion locations) into the C parser.
- jzimmerman64 4y agoThe preprocessor would likely have to be a separate ad-hoc step, but it is possible that langcc could be used to generate a full C frontend if one is willing to run two passes (needed to deal with ambiguous cases such as "x * y", which can be either a multiplication expression or a variable declaration, depending on the contents of the symbol table).
- dontlaugh 4y agoPerl 5 is famously impossible to parse without executing, so no parser will be able to handle it.
- rurban 4y agoThat's not the point. flex is dynamic and can change the AST. langcc should also. perl5 uses a normal flex/bison parser setup.