Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Lexing: how to define tokens based on "context"

by sundialsvc4 (Monsignor)
on Oct 16, 2013 at 13:47 UTC ( #1058445=note: print w/ replies, xml ) Need Help??


in reply to Lexing: how to define tokens based on "context"

That looks like a really nice Lexer, but I must admit that I have become very fond of Parse::RecDescent.   Yes, a full-on parser, driven by a grammar.   I’ve asked that tool to do fairly-ridiculous things, like parsing a conglomeration of SAS programs, Korn shell scripts and Tivoli schedule files ... hundreds of ’em ... and it Just Did It™ with style and grace.   I would basically take that approach instead of building my own program to navigate through the file’s semantic structure, even with a good Lexer by my side.

Furthermore, you can find an EBNF grammar-description for the Sudoers file here:   http://www.sudo.ws/sudoers.man.html.   No, P::RD does not handle such grammars directly (although other Perl parsers do ...), but it shows you outright what the proper grammar structure ought to be.   I think that this might save you a lot of messy coding.


Comment on Re: Lexing: how to define tokens based on "context"
Re^2: Lexing: how to define tokens based on "context"
by three18ti (Scribe) on Oct 17, 2013 at 07:14 UTC

    >> but I must admit that I have become very fond of Parse::RecDescent

    Wow... that looks. complicated... I'm sure if I study the manual long enough I can figure it out. Looks fairly powerful though. Thanks for the link.

    >> Furthermore, you can find an EBNF grammar-description for the Sudoers file here: http://www.sudo.ws/sudoers.man.html.

    You know... when I first started on this project, I found that page but had no idea what an EBNF was. Thanks for pointing that out again, it certainly does help me define my rules.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058445]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2014-09-02 09:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (21 votes), past polls