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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Lexing: how to define tokens based on "context"
by three18ti (Monk) on Oct 17, 2013 at 07:14 UTC |