lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Chris Babcock once stated:
> I have an existing DSL (Diplomacy orders) for which I need to
> implement a parser. The language specification consists of a syntax
> document and a vocabulary document:
> 
> http://aqmn.asciiking.com/data/syntax
> http://aqmn.asciiking.com/data/map
> 
> I need to write a parser that applies the vocabulary to the syntax and
> turns an order stream into an object. There are multiple vocabulary
> documents written in a similar format. I think what I need to write
> may actually be a parser generator. What I need to know, since I will
> be spending many hours on this with little prior background, is LPeg
> the right tool for the job? 

  I don't see why not.  I've been playing around with LPeg for a few months
now, and have written quite a few parsers (JSon, email headers, a very
limited DNS zone file, and a C preprocessor recognizer to name a few).

  Personally, I try to use the re module, as I find that syntax much nicer
than raw LPeg, but there are a few productions in LPeg (folding captures for
instance) that have no syntax in the re module (but you can mix-and-match
LPeg and re though).

  I can attempt to answer any questions, and provide plenty of examples.

  -spc (Really likes LPeg)