This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

38 wiersze
1.2 KiB

  1. class Rule(object):
  2. """
  3. origin : a symbol
  4. expansion : a list of symbols
  5. """
  6. def __init__(self, origin, expansion, alias=None, options=None):
  7. self.origin = origin
  8. self.expansion = expansion
  9. self.alias = alias
  10. self.options = options
  11. def __str__(self):
  12. return '<%s : %s>' % (self.origin, ' '.join(map(str,self.expansion)))
  13. def __repr__(self):
  14. return 'Rule(%r, %r, %r, %r)' % (self.origin, self.expansion, self.alias, self.options)
  15. class RuleOptions:
  16. def __init__(self, keep_all_tokens=False, expand1=False, create_token=None, filter_out=False, priority=None):
  17. self.keep_all_tokens = keep_all_tokens
  18. self.expand1 = expand1
  19. self.create_token = create_token # used for scanless postprocessing
  20. self.priority = priority
  21. self.filter_out = filter_out # remove this rule from the tree
  22. # used for "token"-rules in scanless
  23. def __repr__(self):
  24. return 'RuleOptions(%r, %r, %r, %r, %r)' % (
  25. self.keep_all_tokens,
  26. self.expand1,
  27. self.create_token,
  28. self.priority,
  29. self.filter_out
  30. )