CORRECTION: In the original push, the parser.h file in the parser subdirectory is missing Nterm_def in the TNTtype list. (This was fixed in a push around 2:30pm on the 19th.) CORRECTION TO THE CORRECTION: In the correction I added Nterm_def to the end of the list of non terminals, but left LastNTerm=Nterm_asgn instead of =Nterm_def. That is fixed in the latest push. ADDITIONAL CORRECTION: In parser.c the Nterm_def was also missing from the conv2str function (would come out as "unknown" in output). |
The token rules: VAR [a-z]+ EQ = TERM ; PRINT print INT int REAL real INUM [0-9]+ RNUM [0-9]+[.][0-9]+ The CFG rules: prog --> deflist stmtlist deflist --> def deflist | nil stmtlist --> stmt stmtlist | nil stmt --> VAR EQ asgn TERM | PRINT VAR TERM def --> INT VAR TERM | REAL VAR TERM asgn --> VAR EQ asgn | INUM | RNUM | VARThe tokenizer is based on the tokenizer shown here and discussed in this youtube video. We'll discuss the tokenizing portion of the lab in the lab sessions of Oct. 17-19. The parser is based on the parser shown here and discussed in this youtube video. We'll discuss the parsing portion of the lab in the lab sessions of Oct. 26-28. For both parts of the lab exercise, the program infrastructure is complete, what is left to the student is to finish the code segments related to the actual language tokenizing logic and parsing logic.
Bonus marks: 10% bonus marks if your tokenizer also identifies both the content and token type for each token, e.g. x(VAR), int(INT), ;(SEMI), 1.34(RNUM), 204(INUM) |