This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

92 líneas
2.4 KiB

  1. API Reference
  2. =============
  3. Lark
  4. ----
  5. .. autoclass:: lark.Lark
  6. :members: open, parse, parse_interactive, lex, save, load, get_terminal, open_from_package
  7. Using Unicode character classes with ``regex``
  8. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  9. Python's builtin ``re`` module has a few persistent known bugs and also won't parse
  10. advanced regex features such as character classes.
  11. With ``pip install lark[regex]``, the ``regex`` module will be
  12. installed alongside lark and can act as a drop-in replacement to ``re``.
  13. Any instance of Lark instantiated with ``regex=True`` will use the ``regex`` module instead of ``re``.
  14. For example, we can use character classes to match PEP-3131 compliant Python identifiers:
  15. ::
  16. from lark import Lark
  17. >>> g = Lark(r"""
  18. ?start: NAME
  19. NAME: ID_START ID_CONTINUE*
  20. ID_START: /[\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}_]+/
  21. ID_CONTINUE: ID_START | /[\p{Mn}\p{Mc}\p{Nd}\p{Pc}·]+/
  22. """, regex=True)
  23. >>> g.parse('வணக்கம்')
  24. 'வணக்கம்'
  25. Tree
  26. ----
  27. .. autoclass:: lark.Tree
  28. :members: pretty, find_pred, find_data, iter_subtrees, scan_values,
  29. iter_subtrees_topdown
  30. Token
  31. -----
  32. .. autoclass:: lark.Token
  33. Transformer, Visitor & Interpreter
  34. ----------------------------------
  35. See :doc:`visitors`.
  36. ForestVisitor, ForestTransformer, & TreeForestTransformer
  37. -----------------------------------------------------------
  38. See :doc:`forest`.
  39. UnexpectedInput
  40. ---------------
  41. .. autoclass:: lark.exceptions.UnexpectedInput
  42. :members: get_context, match_examples
  43. .. autoclass:: lark.exceptions.UnexpectedToken
  44. .. autoclass:: lark.exceptions.UnexpectedCharacters
  45. .. autoclass:: lark.exceptions.UnexpectedEOF
  46. InteractiveParser
  47. -----------------
  48. .. autoclass:: lark.parsers.lalr_interactive_parser.InteractiveParser
  49. :members: choices, feed_token, copy, pretty, resume_parse, exhaust_lexer, accepts, as_immutable
  50. .. autoclass:: lark.parsers.lalr_interactive_parser.ImmutableInteractiveParser
  51. :members: choices, feed_token, copy, pretty, resume_parse, exhaust_lexer, accepts, as_mutable
  52. ast_utils
  53. ---------
  54. For an example of using ``ast_utils``, see `/examples/advanced/create_ast.py`_
  55. .. autoclass:: lark.ast_utils.Ast
  56. .. autoclass:: lark.ast_utils.AsList
  57. .. autofunction:: lark.ast_utils.create_transformer
  58. .. _/examples/advanced/create_ast.py: examples/advanced/create_ast.html