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.

32 lines
889 B

  1. from .utils import Serialize
  2. from .lexer import TerminalDef
  3. ###{standalone
  4. class LexerConf(Serialize):
  5. __serialize_fields__ = 'tokens', 'ignore', 'g_regex_flags'
  6. __serialize_namespace__ = TerminalDef,
  7. def __init__(self, tokens, re_module, ignore=(), postlex=None, callbacks=None, g_regex_flags=0, skip_validation=False):
  8. self.tokens = tokens # TODO should be terminals
  9. self.ignore = ignore
  10. self.postlex = postlex
  11. self.callbacks = callbacks or {}
  12. self.g_regex_flags = g_regex_flags
  13. self.re_module = re_module
  14. self.skip_validation = skip_validation
  15. def _deserialize(self):
  16. self.callbacks = {} # TODO
  17. ###}
  18. class ParserConf:
  19. def __init__(self, rules, callbacks, start):
  20. assert isinstance(start, list)
  21. self.rules = rules
  22. self.callbacks = callbacks
  23. self.start = start