Think about Loose Coupling | |
PerlMonks |
Re: Re: Parse::JavaScriptby OeufMayo (Curate) |
on Aug 27, 2002 at 08:45 UTC ( [id://193103]=note: print w/replies, xml ) | Need Help?? |
Thanks for your input podmaster. Here are a few valid JavaScript samples that don't parse too well. Regexes var foo = 3 / 4 + 1 / 2;is parsed as :
var foo = (3/4) + 1 / 2; is not parsed at all (though I suspect it could be fixed by adjusting the precedence) Elisions (though I have yet to see this construct in a real script) var foo = foo[ , , bar];Wrong parsing
Is parsed as:
Which is wrong. the parser should give an error (no line terminator allowed between 'bar' and '++') or be nice and get parse it as bar++;foo; The following code is found in one of the the mozilla/js test script, but it doesn't seem to be valid, according to the specs (and obviously, doesn't parse).
There are probably some more bugs, but the regex/division confusion is by far the most annoying Update here is another major bugs due to the Optional Semicolon:
Should be:
But it is parsed as return a + b;This bug is mainly due to the fact that line terminators are silently skipped by the lexer Update 2002-09-01: I'm glad to say that all these bugs are now fixed in the current version of this node (except for the elision.) -- briac
In Section
Code Catacombs
|
|