JS/CC is the first available parser development system for JavaScript and ECMAScript-derivates so far, and has been developed both with the intention of building a productive compiler development system and creating an easy-to-use learning environment for students and people interested in how parse table generation is done and how bottom-up parsing generally works.
JS/CC unions both: A regular expression-based lexical analyzer generator matching individual tokens from the input character stream and a LALR(1) parse table generator, computing the parse tables for a given context-free grammar specification. Such a context-free grammar is defined in a Backus-Naur-Form-based meta language, and allows the insertion of individual semantic code to be evaluated on a rule's reduction.
JS/CC itself has been entirely written in JavaScript, and is compatible with Microsoft's JScript and JScript.NET, so it can be executed using three different ways: As platform-independent, browser-based JavaScript embedded on a Website, as Windows Script Host Application or as a compiled JScript.NET executable; The current JS/CC distribution provides all three possibilities of execution; However, for productive execution, it is recommended to use the command-line versions, because only these versions are capable of assembling a complete compiler from a JS/CC parser specification, which is then stored to a .js-JavaScript source file.
To use JS/CC and for understanding its internals and behavior, certain knowledge on context-free grammars, bottom-up parsing techniques and compiler construction theories in general is assumed.
It is really incredible, where JS/CC can be invoked from:



JS/CC is capable to compile and run a complete, working parser for any grammar specification with embedded, semantic code segments entirely in a standard web browser like Mozilla Firefox or Microsoft® Internet Explorer.
So feel free and check out the online live installation of JS/CC.
JS/CC is currently provided in the zipped package jscc-0.26.zip and in the Windows setup package jscc-0.26.exe. Both packages come with complete source code, documentation and samples.
To use all features of JS/CC, it is recommended to run it on a Microsoft® Windows® system (for command-line use with Windows Script Host or JScript.NET executable). The browser-based version is platform independent.
To get the latest releases, sources, news and updates in JS/CC, please also visit JS/CC on SF.net!
Please feel free to send any enhancement requests, bug reports or recommendations to jscc[-AT-]jmksf.com.
Thank you!
JS/CC is a non-commercial project of Jan Max Meyer (J.M.K S.F. Software Technologies), and has been released under the terms and conditions of the Artistic License to the public.
Thanks a lot to Louis P. Santillan (lpsantil) for his port of JS/CC to Mozilla/Rhino.
A simple four-function expression calculator is defined with the following few lines of augmented grammar definition to be fed to JS/CC.
/~ --- Token definitions --- ~/
/~ Characters to be ignored ~/
! ' |\t' ;
/~ Non-associative tokens ~/
'\('
'\)'
'[0-9]+' INT [* %match = parseInt( %match ); *]
'[0-9]+\.[0-9]*|[0-9]*\.[0-9]+' FLOAT [* %match = parseFloat( %match ); *]
;
/~ Left-associative tokens, lowest precedence ~/
< '\+'
'\-';
/~ Left-associative tokens, highest precedence ~/
< '\*'
'/';
##
/~ --- Grammar specification --- ~/
p: e [* alert( %1 ); *]
;
e: e '+' e [* %% = %1 + %3; *]
| e '-' e [* %% = %1 - %3; *]
| e '*' e [* %% = %1 * %3; *]
| e '/' e [* %% = %1 / %3; *]
| '-' e &'*' [* %% = %2 * -1; *]
| '(' e ')' [* %% = %2; *]
| INT
| FLOAT
;