Name: Anonymous 2010-11-30 17:46
I want to made a simple programming language, what should I use for parsing:
1. lex + yacc
2. lemon
3. parsec
4. other (what?)
1. lex + yacc
2. lemon
3. parsec
4. other (what?)
digit x -> x.{\0=>0;\1=>1;\2=>2;\3=>3;\4=>4;\5=>5;\6=>6;\7=>7;\8=>8;\9=>9}
number [@xs] -> {r [] => r; r [(x:!digit)@xs] => rec 10r+x xs} 0 xs
op [x] -> x.{\+ => '`+`; \- => '`-`; \* => '`*`; \/ => '`/`}
term x -> x.{[\( @(a:!expr) \)] => [a]; [@(a:!number)] => a}
expr x -> x.{[@(a:!term)] => a; [@(a:!term) @(o:!op) @(b:!expr)] => [o a b]}
strip p l -> l.{x=>x; [@xs !p @ys]=>[@xs @(rec ys)]}
parse string -> string.asList.(strip \Space ?).expr