lua-users home
lua-l archive

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


On Tuesday 17, Igor Medeiros wrote:
> i am sorry for ask something like this, but i did not understand which
> function of lpeg i should use to parser a string which contains a lua code
> sample
> 
> local code = [[
>    --some lua code here
> ]]
> 
> i tried print(lpeg.match(lpeg.P(lua), code)) but it prints just the index
> of first character after the match or nil if the match does not occur
> 
> I need a error message like those showed by lua interpreter when it find a
> syntactic error, instead the nil value printed .
> How can i get this errors messages using the lpeg and the Lua Parser code
> found on this page http://lua-users.org/wiki/LpegRecipes?

Hmm, it looks like there is a better Lua Parser here:
http://leg.luaforge.net/

I had forgotten about it (there was even a link below the parser on the 
LpegRecipes page that I hadn't seen either.

Here is a example that uses the Leg parser:
http://trac-hg.assembla.com/LuaCocoa/browser/leg/examples/comment-
extraction.lua

> 
> Thanks
> Igor
> 
> 
> 
> returns the index in the subject of the first character after the match, or
> the ca <http://www.inf.puc-rio.br/~roberto/lpeg/#captures>
> 
> 2012/7/17 Igor Medeiros <igorosbergster@gmail.com>
> 
> > Thanks by replies.
> > 
> > Best wishes,
> > Igor
> > 
> > 
> > 2012/7/17 Robert G. Jakabosky <bobby@sharedrealm.com>
> > 
> > On Tuesday 17, Igor Medeiros wrote:
> >> > Hi,
> >> > 
> >> > Are there some lua parser done in lua or C available for download? If
> >> 
> >> there
> >> 
> >> > exists, could someone tell me where find it?
> >> 
> >> This page has a Lua Lexer & Lua Parser written in Lua that uses LPeg:
> >> http://lua-users.org/wiki/LpegRecipes
> >> 
> >> 
> >> --
> >> Robert G. Jakabosky


-- 
Robert G. Jakabosky