Created
September 28, 2012 01:18
-
-
Save aji/3797443 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LL(1) parser format: | |
| Terminal symbols: { } [ ] : , STR NUM ID | |
| Rule table: | |
| 0. [invalid] | |
| 1. <json-document> := <object> | |
| 2. <json-document> := <array> | |
| 3. <value> := <object> | |
| 4. <value> := <array> | |
| 5. <value> := STR | |
| 6. <value> := NUM | |
| 7. <value> := ID | |
| 8. <object> := { <obj-body> | |
| 9. <obj-body> := } | |
| 10. <obj-body> := <obj-elems> | |
| 11. <obj-elems> := <obj-elem> <obj-tail> | |
| 12. <obj-tail> := , <obj-elems> | |
| 13. <obj-tail> := } | |
| 14. <obj-elem> := STR : <value> | |
| 15. <array> := [ <arr-body> | |
| 16. <arr-body> := ] | |
| 17. <arr-body> := <arr-elems> | |
| 18. <arr-elems> := <value> <arr-tail> | |
| 19. <arr-tail> := , <arr-elems> | |
| 20. <arr-tail> := ] | |
| Transition table: | |
| { } [ ] : , STR NUM ID | |
| --- --- --- --- --- --- --- --- --- | |
| json-document 1 2 | |
| value 3 4 5 6 7 | |
| object 8 | |
| obj-body 9 10 | |
| obj-elems 11 | |
| obj-tail 13 12 | |
| obj-elem 14 | |
| array 15 | |
| arr-body 18 18 16 18 18 18 | |
| arr-elems 3 4 5 6 7 | |
| arr-tail 20 19 | |
| These two tables are effectively a program for an LL(1) parser. The | |
| hard work has been done. The remaining steps are to attach appropriate | |
| actions to the rules above, and to implement the LL(1) parsing | |
| algorithm. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment