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.

37 lines
1.1 KiB

  1. import logging
  2. from .utils import Serialize
  3. from .lexer import TerminalDef
  4. logger = logging.getLogger("lark")
  5. logger.addHandler(logging.StreamHandler())
  6. # Set to highest level, since we have some warnings amongst the code
  7. # By default, we should not output any log messages
  8. logger.setLevel(logging.CRITICAL)
  9. ###{standalone
  10. class LexerConf(Serialize):
  11. __serialize_fields__ = 'tokens', 'ignore', 'g_regex_flags', 'use_bytes'
  12. __serialize_namespace__ = TerminalDef,
  13. def __init__(self, tokens, re_module, ignore=(), postlex=None, callbacks=None, g_regex_flags=0, skip_validation=False, use_bytes=False):
  14. self.tokens = tokens # TODO should be terminals
  15. self.ignore = ignore
  16. self.postlex = postlex
  17. self.callbacks = callbacks or {}
  18. self.g_regex_flags = g_regex_flags
  19. self.re_module = re_module
  20. self.skip_validation = skip_validation
  21. self.use_bytes = use_bytes
  22. ###}
  23. class ParserConf:
  24. def __init__(self, rules, callbacks, start):
  25. assert isinstance(start, list)
  26. self.rules = rules
  27. self.callbacks = callbacks
  28. self.start = start