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.

30 lines
743 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, ignore=(), postlex=None, callbacks=None, g_regex_flags=0):
  8. self.tokens = tokens
  9. self.ignore = ignore
  10. self.postlex = postlex
  11. self.callbacks = callbacks or {}
  12. self.g_regex_flags = g_regex_flags
  13. def _deserialize(self):
  14. self.callbacks = {} # TODO
  15. ###}
  16. class ParserConf:
  17. def __init__(self, rules, callbacks, start):
  18. assert isinstance(start, list)
  19. self.rules = rules
  20. self.callbacks = callbacks
  21. self.start = start