Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How easy is it to make quick changes to hand-written parsers.

Imagine, for example, that the input being parsed is not under the authors control and it suddenly changes. The parser must be changed.



The input changing shouldn't matter. Maybe you could see a performance issue if you had to parse a really large file/files. The issue would be if the grammar to what you are parsing changes. If that changes, then no parser will work, correctly until it supports the new grammar.

As a practical matter the grammar can act like a contract between the two systems. You don't have control of the input, but the input must follow the same grammar.


Does the separation of the grammar into its own file, like a .y file for yacc, make it easier to modify the grammar at a later point. Similarly, is it easier to modify a parser later on, if the input changes, if the patterns to be searched in the input and the state machine are stored in a separate file, like an .l file for flex.


I would think so.

I don't work on parsers and grammar day to day, so I might not be the best person to ask about this. I am interested in the subject though. I just don't get to work on this in my current day job.


It is super easy to change. It is just normal code.


Why then do people use programs like ANTLR, Ragel, Lemon/re2c, etc.


Probably because they don’t know how to write parsers by hand and assume it is hard?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: