in reply to Re: Parse::JavaScript
in thread JavaScript::Parse::PurePerl (was Parse::JavaScript)
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;
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
bar ++foo;
Is parsed as:
bar++; foo;
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).
try { //some stuff }catch (e if e == 3){ /* do stuff */ }
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:
return a + b
Should be:
return; a + b;
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Parse::JavaScript
by Corion (Patriarch) on Aug 27, 2002 at 19:47 UTC | |
Re^3: Parse::JavaScript
by Anonymous Monk on Mar 11, 2016 at 03:21 UTC |