LPEG code for JavaScript grammar?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

LPEG code for JavaScript grammar?

Duck-2
I suppose I mean "a grammar for the language specified in 
ECMA-262 ECMAScript Language Specification 3rd edition" :-)

A big ask, I know, but...does LPEG code for this exist? If not, does 
anyone have a PEG grammar in some textual form which might be converted 
fairly simply into an LPEG-based equivalent?

(My first thought was "just convert the grammar in the ECMA-262 document 
into LPEG form -- after all, it's only programming", but that was before I 
downloaded the 188-page beast of a specification! Compare that to the 95 
less-densely-packed and readable pages of the entire Lua 5.1 _Reference_ 
Manual. What a sheltered world a Luaphile enjoys :- )

Reply | Threaded
Open this post in threaded view
|

Re: LPEG code for JavaScript grammar?

Jeff Pohlmeyer
On Thu, Apr 3, 2008 at 4:03 PM, Duck <[hidden email]> wrote:

>  A big ask, I know, but...does LPEG code for this exist? If not, does
>  anyone have a PEG grammar in some textual form which might be converted
>  fairly simply into an LPEG-based equivalent?

Here is a vintage 1998 lex/yacc grammar that might be a starting point:

http://www.soton.net/jssyntaxchecker/code.html


- Jeff

Reply | Threaded
Open this post in threaded view
|

Re: LPEG code for JavaScript grammar?

Fabio Mascarenhas
In reply to this post by Duck-2
There is a JavaScript grammar for OMeta
(http://www.cs.ucla.edu/~awarth/ometa/), which is also based on PEGs,
it may be a start.

--
Fabio Mascarenhas

On Thu, Apr 3, 2008 at 6:03 PM, Duck <[hidden email]> wrote:
>
>  I suppose I mean "a grammar for the language specified in
>  ECMA-262 ECMAScript Language Specification 3rd edition" :-)
>
>  A big ask, I know, but...does LPEG code for this exist? If not, does
>  anyone have a PEG grammar in some textual form which might be converted
>  fairly simply into an LPEG-based equivalent?
>
>  (My first thought was "just convert the grammar in the ECMA-262 document
>  into LPEG form -- after all, it's only programming", but that was before I
>  downloaded the 188-page beast of a specification! Compare that to the 95
>  less-densely-packed and readable pages of the entire Lua 5.1 _Reference_
>  Manual. What a sheltered world a Luaphile enjoys :- )
>

Reply | Threaded
Open this post in threaded view
|

Re: LPEG code for JavaScript grammar?

David Given
In reply to this post by Duck-2
Duck wrote:
> I suppose I mean "a grammar for the language specified in 
> ECMA-262 ECMAScript Language Specification 3rd edition" :-)
> 
> A big ask, I know, but...does LPEG code for this exist? If not, does 
> anyone have a PEG grammar in some textual form which might be converted 
> fairly simply into an LPEG-based equivalent?
[...]

IIRC Javascript has some rather peculiar rules when it comes to
replacing missing semicolons that may make it hard to parse. Certainly,
a while back I tried putting together a yacc grammar for it and
basically ended up having to give up.

If anyone had an LPEG grammar, though, I'd love to use it...

-- 
ââââ ïïïïïïïïïïïïïï âââââ http://www.cowlark.com âââââ
â "I have always wished for my computer to be as easy to use as my
â telephone; my wish has come true because I can no longer figure out
â how to use my telephone." --- Bjarne Stroustrup

Attachment: signature.asc
Description: OpenPGP digital signature

Reply | Threaded
Open this post in threaded view
|

Re: LPEG code for JavaScript grammar?

Mark Hamburg-4
Does anyone know if JavaScript's syntax was driven by what the first
implementation happened to do rather than by a formal grammar?

Mark



Reply | Threaded
Open this post in threaded view
|

Re: LPEG code for JavaScript grammar?

Mike Pall-84
Mark Hamburg wrote:
> Does anyone know if JavaScript's syntax was driven by what the first
> implementation happened to do rather than by a formal grammar?

This is very likely, given its history:
  http://www.mozilla.org/js/language/ICFP-Keynote.ppt  (560K PPT)

--Mike

Reply | Threaded
Open this post in threaded view
|

Re: LPEG code for JavaScript grammar?

John Belmonte
In reply to this post by Duck-2
On Thu, Apr 3, 2008 at 5:03 PM, Duck <[hidden email]> wrote:
>
>  I suppose I mean "a grammar for the language specified in
>  ECMA-262 ECMAScript Language Specification 3rd edition" :-)
>
>  A big ask, I know, but...does LPEG code for this exist? If not, does
>  anyone have a PEG grammar in some textual form which might be converted
>  fairly simply into an LPEG-based equivalent?

Not really what you asked for, but for those who enjoy reading
JavaScript take a look at the jsdefs and jsparse files of Narcissus
(http://lxr.mozilla.org/mozilla/source/js/narcissus/).