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.

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