lua-users home
lua-l archive

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


I recommend you to look http://lua-users.org/wiki/LpegRecipes
In this page you will see more examples with LPeg.

good luck

On Thu, Nov 18, 2010 at 10:40 AM, Humberto Aranha <humberto.aranha@interagente.com> wrote:
See: http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html#intro
It contains references and examples.

-Humberto Aranha
----- Original Message ----- From: "Lorenzo Donati" <lorenzodonatibz@interfree.it>
To: "Lua List" <lua-l@lists.lua.org>
Sent: Thursday, November 18, 2010 5:57 AM
Subject: LPEG primer



Hi list!

I'm planning in the near future to start learning to use LPEG as a more powerful alternative to regexes and Lua patterns (with added readability and maintenance ease). Is there a good freely-available in-depth primer/tutorial for that?

I've searched the internet for PEG and LPEG, but everything I found was rather heavy on the Computer Science side. Although my CS skills are not zero, they are still basic on the theoretical side. I know how to read EBNF-like specs and know what a parser or lexer are and their general working principles, but definitely I am not able to design a grammar taking into account operator precedence, ambiguity, left-recursion and the like (not that I need that so much, but only to give a hint to my skill level).

Therefore I'd need something practical, more focused on pattern matching than on parsing languages. I need LPEG essentially for text searches and simple string parsing for DSLs (very simple, math-like expressions especially) - I cannot give more information on the specific needs because for now I'd only like to learn LPEG in the hope it will help me in the tasks for which I usually employ (sometimes fairly complex and ugly) regexes.

I only found an article by Gavin Wraith, but it is from 1997 and I don't know if it is still current now that LPEG 0.10 has come out.
Moreover it is still a bit concise, albeit fairly clear. I also skimmed through a scientific paper by Roberto, but although it gave me some more hints, it was rather focused on the implementation of LPEG and less on its practical use (of course I understand it was not meant as a tutorial for non computer scientists). I also gave a look to LPEG recipes in the Wiki, but I found them rather obscure (I realized I miss enough LPEG background for those).


Any pointer is appreciated.
Thanks!

-- Lorenzo







--
Marcelo Oikawa