Categories

Support Wikipedia

Perl RecDescent Parser Generator

For one of my projects where I needed to convert a legacy register description of a chip to a newer language. This needed to be done in a fairly short time. I had to build a parser to read a set of register description files from a 15 year old project to start with. I considered various options – write a parser by hand, use something like Lex/Yacc or ANTLR, etc. I had done some work the the Perl RecDescent module in the past, and I thought I would give it a try.

I quickly looked up an example I had created with RecDescent, that I had saved in my handy Google Docs. It only took me a few minutes to remember what I had done the last time with RecDescent.

I copied the example, and started adding the grammar for the register format that I had to process. In about a day, I pretty much had the parser done, and I could write out an XML description. The next step was to read in the XML and write out a different form of register description. More about that in another post.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>