paul_nicholls
01-02-2011, 10:51 AM
Hi all,
During my work with my Pas2C64 (http://www.pascalgamedevelopment.com/showthread.php?6660-Pas2C64) parser I have been working on, I decided to create a generic parser class that anyone can use as a starting point, and sub-class it to make more specific parsers :)
Here is the base parser and base parser type units (with .txt after the .pas to allow uploading):
214
215
I have based it on the recursive descent parser shown here (C code):
http://en.wikipedia.org/wiki/Recursive_descent_parser
You must subclass the parser to use it. See the attached file below (with .txt after the .dpr):
216
You Register all generic tokens and keyword tokens with the parser (see the base parser file for an example; this can be moved into a concrete parser types file (or similar) if you prefer).
You then test for the token values in the parser just like in the attached program example :)
Enjoy!
cheers,
Paul
During my work with my Pas2C64 (http://www.pascalgamedevelopment.com/showthread.php?6660-Pas2C64) parser I have been working on, I decided to create a generic parser class that anyone can use as a starting point, and sub-class it to make more specific parsers :)
Here is the base parser and base parser type units (with .txt after the .pas to allow uploading):
214
215
I have based it on the recursive descent parser shown here (C code):
http://en.wikipedia.org/wiki/Recursive_descent_parser
You must subclass the parser to use it. See the attached file below (with .txt after the .dpr):
216
You Register all generic tokens and keyword tokens with the parser (see the base parser file for an example; this can be moved into a concrete parser types file (or similar) if you prefer).
You then test for the token values in the parser just like in the attached program example :)
Enjoy!
cheers,
Paul