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.0 KiB

  1. from warnings import warn
  2. from .utils import Serialize
  3. from .lexer import TerminalDef
  4. ###{standalone
  5. class LexerConf(Serialize):
  6. __serialize_fields__ = 'terminals', 'ignore', 'g_regex_flags', 'use_bytes'
  7. __serialize_namespace__ = TerminalDef,
  8. def __init__(self, terminals, re_module, ignore=(), postlex=None, callbacks=None, g_regex_flags=0, skip_validation=False, use_bytes=False):
  9. self.terminals = terminals
  10. self.ignore = ignore
  11. self.postlex = postlex
  12. self.callbacks = callbacks or {}
  13. self.g_regex_flags = g_regex_flags
  14. self.re_module = re_module
  15. self.skip_validation = skip_validation
  16. self.use_bytes = use_bytes
  17. @property
  18. def tokens(self):
  19. warn("LexerConf.tokens is deprecated. Use LexerConf.terminals instead", DeprecationWarning)
  20. return self.terminals
  21. ###}
  22. class ParserConf:
  23. def __init__(self, rules, callbacks, start):
  24. assert isinstance(start, list)
  25. self.rules = rules
  26. self.callbacks = callbacks
  27. self.start = start