dypgen is a GLR parser generator for Objective Caml. It can generate dynamically
extensible parsers.
The program is available at :
http://perso.ens-lyon.fr/emmanuel.onzon
Here is are two examples of extension of a small language.
This is the example included with the program.
define
list_content := expr(x) = List(x,Nil)
and list_content := expr(x);list_content(y) = List(x,y)
and expr := [] = Nil
and expr := [list_content(x)] = x
and expr := expr(x)::expr(y) = List(x,y)
in
match [1;2;3] with
| a::[b;c] -> b
| _ -> 4
define
expr := | expr(x) | = Node(Leaf,x,Leaf)
and expr := expr(x) | expr(y) | = Node(x,y,Leaf)
and expr := | expr(x) | expr(y) = Node(Leaf,x,y)
and expr := expr(x) | expr(y) | expr(z) = Node(x,y,z)
in
match Node(Leaf,3,Node(Node(Leaf,7,Leaf),5,Node(Leaf,1,Leaf))) with
| (|3|((|7|)|a|(|1|))) -> a
| _ -> 8
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs