Known Parsing challenges?
samuelgoto opened this issue · 0 comments
samuelgoto commented
(porting @Waldemar's comments into github issues)
@Waldemar: is it possible to avoid "cover grammars"? Is it possible to make a distinction between syntax expressions and type expressions? For example:
// How does a parser know whether "<" is a "less-than" token or a "open-generic"
// token without looking ahead?
... a: b<c> ...
// Arrow functions introduced a similar challenge, take the following example:
... (a, b) ...
// One only knows whether that's a "parenthesis expression" ->
// "comma expression" -> "variable reference" or
// "parameter list" -> "parameter" **after** seeing the token "=>".
// So that
... (a, b) => ....
// Is parsed differently than
... (a, b); ...
// And that introduces complexity in the parser as well as security challenges
// whitelisting programs.
@Waldemar used a term to describe grammars that saved the tokens in a "union"-like structure and that resolved the ambiguity at later stages of parsing ("cover grammar"?), as something to be avoided (e.g. leads to complexity and leads to security challenges whitelisting programs). He cited arrow functions (=>) as an example. Reach out to find what is the right term.