On 2010-07-01, at 10:59 AM, chevalma@iro.umontreal.ca wrote:
It seems that some syntax errors are not detected by the parser. For example, a break statement outside of a loop/switch statement, or with an invalid label does not generate a syntax error. I would suggest that the parser should have an AST validation pass added to it, so that these kinds of errors can be detected, and adequately reported, before any transformations are applied to the AST.
Right now, I'm in a position where the parser can produce an AST that doesn't translate into valid IR. I would rather avoid having to clutter the AST->IR translation with validation and syntax error reporting code, and simply be able to assume that the AST I get as input is syntactically valid.
Absolutely! There are currently no checks in the parser beyond the grammatical checks. It allows things like:
1 = 2+3;
because that is allowed by the ECMAScript grammar.
The best place to add such checks is probably in the AST normalizer (ast-passes.js) because it already traverses the AST for accumulating various informations on the AST.
Who can add this task to their workload?
Marc