项目作者: itsmeashutosh43

项目描述 :
A implementation of LR(1) Parser or CLR Parser in Python3.
高级语言: Python
项目地址: git://github.com/itsmeashutosh43/LR-1-parser-in-Python-Closure-and-Parse-table-.git


LR-1-parser-in-Python-Closure-and-Parse-table-

A implementation of LR(1) Parser or CLR Parser in Python3.

input(edit in line number 268)

  1. 'S::=CC',
  2. 'C::=cC',
  3. 'C::=d'

Output>>

  1. {'0+S': 'shift 2', '0+C': 'shift 3', '0+c': 'shift 10', '0+d': 'shift 8',
  2. '1+d': 'reduce C::=d', '1+c': 'reduce C::=d', '2+$': 'reduce ^::=S', '3+C': 'shift 6',
  3. '3+c': 'shift 7', '3+d': 'shift 5', '4+C': 'shift 12', '4+c': 'shift 10', '4+d': 'shift 8',
  4. '5+$': 'reduce C::=d', '6+$': 'reduce S::=CC', '7+C': 'shift 11', '7+c': 'shift 7',
  5. '7+d': 'shift 5', '8+d': 'reduce C::=d', '9+d': 'reduce C::=cC', '9+c': 'reduce C::=cC',
  6. '10+C': 'shift 12', '10+c': 'shift 10', '10+d': 'shift 8', '11+$': 'reduce C::=cC', '12+d': 'reduce C::=cC'}


(Contents Of Parsing Table)
where an entry,
5+$: ‘reduce C::=d’ represents reduction in state 5 , under $ symbol from d to C.

  1. State 0
  2. [['^::=.S$'], ['S::=.CC$'], ['C::=.cCd'], ['C::=.cCc'], ['C::=.dd'], ['C::=.dc']]
  3. *********************
  4. State 1
  5. [['C::=d.d'], ['C::=d.c']]
  6. *********************
  7. State 2
  8. [['^::=S.$']]
  9. *********************
  10. State 3
  11. [['S::=C.C$'], ['C::=.cC$'], ['C::=.d$']]
  12. *********************
  13. State 4
  14. [['C::=c.Cd'], ['C::=c.Cc'], ['C::=.cCd'], ['C::=.dd']]
  15. *********************
  16. State 5
  17. [['C::=d.$']]
  18. *********************
  19. State 6
  20. [['S::=CC.$']]
  21. *********************
  22. State 7
  23. [['C::=c.C$'], ['C::=.cC$'], ['C::=.d$']]
  24. *********************
  25. State 8
  26. [['C::=d.d']]
  27. *********************
  28. State 9
  29. [['C::=cC.d'], ['C::=cC.c']]
  30. *********************
  31. State 10
  32. [['C::=c.Cd'], ['C::=.cCd'], ['C::=.dd']]
  33. *********************
  34. State 11
  35. [['C::=cC.$']]
  36. *********************
  37. State 12
  38. [['C::=cC.d']]
  39. *********************