Professional Documents
Culture Documents
For example, the followings are some possible production rules for a CFG: S -> aS S -> bA S -> A -> c A -> bAb
The non-terminals and the terminals of the given CFG are the non-terminals and the terminals appearing in the given production rules. The starting non-terminal is S. You may assume that the syntax of the production rules (as described above) is correct, and you do not have to handle the incorrect ones. If the given CFG is not a LR(1) grammar, your program should print a message indicating this fact together with the reason (which entries contain conflicts). If the given CFG is a LR(1) grammar, it should create its LR(1) parsing tables, and store it internally. Your program should also print that LR(1) parsing tables together with the canonical LR(1) collection into a file. Parse A String If there are LR(1) parsing tables that are created, your program should read a string and should parse using those LR(1) parsing tables. If the given string is in the language of the current grammar, your program should print its rightmost derivation. If it is not, your program should give error messages. Your program should give the positions of the errors together with error messages. Your program should use panic-mode error recovery to be able to give multiple error messages. For example, if the current grammar is the CFG above and the given string is abc , your program should print the following rightmost derivation below: S => aS => abA => abc For example, if the given string is an erroneous string abbab, it should print the following error message Error: Unexpected a in A at the position 4.
You should hand-in: Your source program (email to your assistant (Turhan Daybelge) ( daybelge@cs.bilkent.edu.tr )) Some test runs of your program with correct and incorrect strings (email to the assistant) Executable of the your program by email and a message indicating how to run your executable on a PC or a Unix machine which is available at our department.