Recursive descent parser generator: Difference between revisions
(Adding this as a very rough draft. Still needs a lot of specification before any examples can be added.) |
mNo edit summary |
||
Line 10: | Line 10: | ||
</pre> |
</pre> |
||
The first section contains the token definitions. Each line contains the name of a token followed by a regular expression. Tokens are to be matched greedily in the order given. The token section ends with a blank line. |
The first section contains the token definitions. Each line contains the name of a token followed by a regular expression. If your language does not have support for regular expressions, you can use something simpler, but make a note of the details. Tokens are to be matched greedily in the order given. The token section ends with a blank line. |
||
The second section contains the production rules. Each rule consists of a non-terminal symbol and [more work needs to be done on this part of the task]. You can assume that all of the rules have been preprocessed into a form suitable for the construction of a recursive descent parser. See here for more details: http://www.cs.engr.uky.edu/~lewis/essays/compilers/rec-des.html |
The second section contains the production rules. Each rule consists of a non-terminal symbol and [more work needs to be done on this part of the task]. You can assume that all of the rules have been preprocessed into a form suitable for the construction of a recursive descent parser. See here for more details: http://www.cs.engr.uky.edu/~lewis/essays/compilers/rec-des.html |
Revision as of 05:47, 2 April 2014
Write a recursive descent parser generator that takes input in the following format and outputs the source code for a parser in the same language as the generator. (So a generator written in C++ would output C++ source code for the parser.)
Input format:
var [a-z]+ ...
The first section contains the token definitions. Each line contains the name of a token followed by a regular expression. If your language does not have support for regular expressions, you can use something simpler, but make a note of the details. Tokens are to be matched greedily in the order given. The token section ends with a blank line.
The second section contains the production rules. Each rule consists of a non-terminal symbol and [more work needs to be done on this part of the task]. You can assume that all of the rules have been preprocessed into a form suitable for the construction of a recursive descent parser. See here for more details: http://www.cs.engr.uky.edu/~lewis/essays/compilers/rec-des.html