in reply to Conditional continued matching with regexes

What would *I* do? Write a parser. ^^

No... really.

Edit: Technically - a regexp is a parser where the language is the regexp, but I'd use something ala Rec::Descent. :)

  • Comment on Re: Conditional continued matching with regexes

Replies are listed 'Best First'.
Re^2: Conditional continued matching with regexes
by BrowserUk (Patriarch) on Feb 06, 2007 at 03:24 UTC

    Wouldn't a Parser::RecDescent solution suffer exactly the same problems?

    Wouldn't you either have to load the entire file and parse it as a single lump; or parse it line by line until the parser failed, append the next line to the failed line and then re-attempt from the beginning?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Yup. But doing all the logic in a regexp feels less comfortable to me. I'm just more versed in parser/lexer's for logic that is more complex. The entire putting perl code within regexp's is fine, just not my way.

      After all, bart asked me what would *I* do. :)

Re^2: Conditional continued matching with regexes
by bart (Canon) on Feb 06, 2007 at 08:14 UTC
    What use is a parser, when a lexer will do?

    "When all you have is a hammer, every problem looks like a nail." And a parser is an excellent hammer.

    What I mean is: there's nothing remotely recursive in the definition of the syntax of CSV. Which is when you need to use a parser.

      Hey, you asked what I'd use. I wouldn't use a regexp. Not because it's wrong, but what you posted, while may work, is not the easiest thing for me to just mind dump into code.

      Was it your intention to ask what *I* would do and then critique me on it? If that were to happen, I never would have answered at all.