Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: 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;

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

In reply to Re: Re: Parse::JavaScript by OeufMayo
in thread JavaScript::Parse::PurePerl (was Parse::JavaScript) by OeufMayo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (6)
    As of 2015-07-31 01:57 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (274 votes), past polls