Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
bug in "developing applications with objective caml" (english translation)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-04-04 (03:42)
From: Jack Andrews <effbiae@i...>
Subject: Re: some comments on ocaml{lex,yacc} from a novice's POV
Jack Andrews said:
> have used ply (python lex-yacc) most recently for parsing and believe it
> to be one of the more elegant mechanisms i've seen.
> elegant because there are no lex and yacc input files, but rather the
> tokens and grammar rules are defined in python code -- succinctly!

i've now found the most elegant parser generator i have seen (scheme):

here's the usual calc example that generates a parser:

 (define expr-parser
   ; Terminal symbols
   (ID + - * /)
   ; Productions
   (e (e + t)    : (+ $1 $3)
      (e - t)    : (- $1 $3)
      (t)        : $1)
   (t (t * f)    : (* $1 $3)
      (t / f)    : (/ $1 $3)
      (f)        : $1)
   (f (ID)       : $1)))

isn't that nice?!?  this is an example of the power of lisp macros that
paul graham talks about.

compare with caml solutions? compare with any other solution?

i'm genuinely trying to choose my next language.  i was drawn to ocaml
because it's a fast, functional language: i want that power without having
to optimize to C.  i'm told there are good scheme compilers.  i was drawn
to ocaml because of it's score in the "language shootout"(s) and because
of it's high placing in the programming contest.

so this post is a troll, i guess, but i want to make an informed choice.

tia,   jack