in reply to Writing a parser

It looks like you can just iterate over the lines, and check with regexes if the line starts with #, and split at whitespaces.

But you have to be a bit more specific about the syntax, and what you want the parser to do with it (generate a parse tree? or an abstract syntax tree? Or execute it straight away?)

Replies are listed 'Best First'.
Re^2: Writing a parser
by pc88mxer (Vicar) on Jan 29, 2008 at 20:21 UTC
    Just based on what you are telling us, I would second this approach. I've written the following code many times:

    while (<FH>) { s/#.*$//; my @args = split(' ', $_); next unless @args; ... process command ... }

    If, however, you have any recursive syntactical elements (like begin/end grouping symbols which need to be matched), a proper parser written with Parser::RecDescent is probably in order.