README 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. Welcome to PyBison
  2. Bringing GNU Bison/Flex's raw speed and power to Python
  3. 1) What is PyBison?
  4. PyBison is a framework which effectively 'wraps' Bison and Flex into a Python
  5. class structure.
  6. You define a parser class, define tokens and precedences as attributes,
  7. and parse targets as methods with rules in the docstrings,
  8. then instantiate and run.
  9. Black Magick happens in the background, whereupon you get callbacks each
  10. time yyparse() resolves a parse target.
  11. 2) There are already parsers for Python. Why re-invent the wheel?
  12. I looked at all the Python-based parsing frameworks.
  13. IMO, the best one was PLY - a pure-python lexx/yacc implementation
  14. (which I have borrowed from heavily in designing PyBison's OO model).
  15. But PLY suffers some major limitations:
  16. * usage of 'named groups' regular expressions in the lexer creates
  17. a hard limit of 100 tokens - not enough to comfortably handle major
  18. languages
  19. * pure-python implementation is a convenience, but incurs a cruel
  20. performance penalty
  21. * the parser engine is SLR, not full LALR(1)
  22. The other frameworks utilise a fiddly script syntax -
  23. 3) How do I use this?
  24. Refer to the INSTALL file for setting up.
  25. Refer to the examples and the doco for usage.