This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.7 KiB

  1. API Reference
  2. =============
  3. Lark
  4. ----
  5. .. autoclass:: lark.Lark
  6. :members: open, parse, save, load
  7. **Using Unicode character classes with regex**
  8. Python's builtin `re` module has a few persistent known bugs and also won't parse
  9. advanced regex features such as character classes.
  10. With `pip install lark-parser[regex]`, the `regex` module will be installed alongside `lark` and can act as a drop-in replacement to `re`.
  11. Any instance of `Lark` instantiated with `regex=True` will now use the `regex` module instead of `re`.
  12. For example, we can now use character classes to match PEP-3131 compliant Python identifiers.
  13. Example:
  14. ::
  15. from lark import Lark
  16. >>> g = Lark(r"""
  17. ?start: NAME
  18. NAME: ID_START ID_CONTINUE*
  19. ID_START: /[\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}_]+/
  20. ID_CONTINUE: ID_START | /[\p{Mn}\p{Mc}\p{Nd}\p{Pc}·]+/
  21. """, regex=True)
  22. >>> g.parse('வணக்கம்')
  23. 'வணக்கம்'
  24. Tree
  25. ----
  26. .. autoclass:: lark.Tree
  27. :members: pretty, find_pred, find_data, iter_subtrees,
  28. iter_subtrees_topdown
  29. Token
  30. -----
  31. .. autoclass:: lark.Token
  32. Transformer, Visitor & Interpreter
  33. ---------------------------------
  34. See :doc:`visitors`.
  35. UnexpectedInput
  36. ---------------
  37. .. autoclass:: lark.exceptions.UnexpectedInput
  38. :members: get_context, match_examples
  39. .. autoclass:: lark.exceptions.UnexpectedToken
  40. .. autoclass:: lark.exceptions.UnexpectedCharacters
  41. ParserPuppet
  42. ------------
  43. .. autoclass:: lark.parsers.lalr_puppet.ParserPuppet
  44. :members: choices, feed_token, copy, pretty, resume_parse