October 2013 Archives

Jperl

Now that MarpaX::Languages::ECMA::AST is on the road, I can start effectively my exciting project: Jperl, i.e. JavaScript engine writen in perl thanks to the only but so great BNF parser: Marpa.

Marpa Hint: matching an integer

I will not reinvent the wheel and take the exact definition from the C grammar in its Lex format:

{HP}{H}+{IS}?	 { return I_CONSTANT; }
{NZ}{D}*{IS}?	 { return I_CONSTANT; }
"0"{O}*{IS}?	 { return I_CONSTANT; }
{CP}?"'"([^'\\\n]|{ES})+"'"	 { return I_CONSTANT; }
How does it translate into Marpa grammar ? The first question always have to be: am I talking about a terminal or a non-terminal ? Here obviously the answer is: a terminal. So for Marpa this will be a lexeme. With Marpa a lexeme is the "bridge" between high-level rules (the usual "grammar") and low-level rules (how a…

(my) Marpa Best Practices

Marpa is a great, really great, piece of software that deserve to be used by everybody wanting to do serious (let's say frankly: professional) and innovative parsing. I feel that Perl language is very lucky to to have been choosen by its author, Jeffrey Kegler, as the main frontend. But seriously, this is the only module that is a true BNF parser. All others modules on CPAN that contain the BNF keyword are not. Marpa brings innovative and on-the-edge ways of…

About Jean-Damien Durand

user-pic About::Me::And::Perl