earley-example.k 440 B

12345678910111213141516171819202122232425262728293031
  1. \l earley.k
  2. para:`0:
  3. T:(("S:aS|b";"aab")
  4. ("e:NNe|Ne|";"NNN"))
  5. para"parse grammar \"",p[0], "\" with input \"",((p:T 1)1),"\""
  6. para""
  7. (d;t):rec. p
  8. para"result table"
  9. t
  10. para""
  11. para"result internal data"
  12. d
  13. para""
  14. (rules;itms):dsp[d;t]
  15. para"List of productions"
  16. rules
  17. para""
  18. para"Table of items"
  19. `0:,/'$/|1(2+|/#',/)\($!#itms),'((-1_d[`i]),"-"),'itms
  20. para""
  21. para"trees"
  22. `0:`k'trees[d;t;itms]
  23. para""
  24. para"More explanation to come ..."