News
Workshop interne avec l’équipe de l’EPFL-ECAL-lab pour évaluer lubyk. Si tout va bien, on aura quelques démos à mettre en ligne…
Nous travaillons actuellement sur le spectacle des bateaux pour nulle part prévu pour l’automne 2012.
Generating a parser with lemon
Why create a parser by hand for the rubyk patches when you can write the grammar and let lemon do the job ? It’s time for “lemon tea”.
I chose lemon over alternatives like ANTLR or bison because it is easy to use, less error prone and interfaces well with C++. Even if ANTLR seems good, it’s written in Java and … it’s a mess to use (for me).
I wrote a simple command line tool to try lemon with flex. The code is adapted from the examples of Mike Chirico.
flex creates the “token generator”, this thing that says “here’s a number”, “and that’s a word”, “this is punctuation”. These tokens (labels) are then fed into the parser created by lemon from the grammar. The parser makes clever decisions based on the tokens sequence.
The code is here :
41 Kb |
Simple command line written using lemon |
To try this simple tool, just type (you need flex installed) :
# make # ./test Parser started. > Hello World ! {Hello} {World} |!| > quit Bye...
From this simple template it should not be too easy to make a real tool.
Have fun !