Writing text parsers with yacc and lex

Posted by

Lex and yacc are two tools that you may be aware of, but have maybe never used. They are key components to compilers, configuration tools and many different languages, where the ability to parse text and generate some other output (assembly code, or simply to understand the contents). To explain how the system works, I have a new tutorial at IBM developerWorks. Entitle Writing text parsers with yac and lex, the tutorial primarily focuses on how the two tools work. To demonstrate the significance of precedence (order of execution) and structure, I use calculators as the main example, before moving on to how to parse and understand text. You can read the article through this link, but you may also want to use the additional examples that I placed onto MCslp Coalface.There are two follow-up articles:

These demonstrate how you can modify the output generated by, for example, an RPN parser so that it outputs normal equations, and vice versa. There’s an example in the tutorial the covers shows how you can link these two together.