lua-users home
lua-l archive

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


On 24/09/2013 11:44 AM, Jayanth Acharya wrote:
Went through 3-4 different sources to understand how to use LPEG. Just can't seem to cross the chasm, in beginning to comprehend how to use it. I've to admit, that I have grappled with PEG as well (the Wiki page). I am beginning to think that I need to develop a level of expertise of Lua, before I can step-up to understanding something like LPEG. The way the grammar is described... seems so unusual, and syntactically doesn't look like Lua.

Is there a layman friendly, step-by-step tutorial explaining PEG and usage of LPEG ?

I'm another layman wanting to grok LPeg. I come from a mainframe background where the lingua franca is REXX. Lua really does nuke REXX in just about every aspect other than simplicity of parsing.

Take the following output from a netstat command.

Client Name: SMTP                     Client Id: 000000B7
  Local Socket: 0.0.0.0..1049
  Foreign Socket: *..*
    BytesIn:            00000000000000493311
    BytesOut:           00000000000000366747
    DgramIn:            00000000000000008397
    DgramOut:           00000000000000008529
    Last Touched:       10:51:10
    MaxSendLim:         0000065535       MaxRecvLim: 0000065535
    SockOpt:            D0000000         DSField:            00
    QOSPolicy:          No
    RoutingPolicy:      No
    ReceiveDataQueued:  0000000000       ReceiveMsgCnt: 0000000000

I would love to learn how to write LPeg parser to yank the key->values from that multi-line report easily. I know it can be done I just can't work it out because I'm a neophyte.