2 # -*- coding: utf-8 -*-
6 # This file was automatically generated by Grako.
8 # https://pypi.python.org/pypi/grako/
10 # Any changes you make to it will be overwritten the next time
11 # the file is generated.
14 from __future__ import print_function, division, absolute_import, unicode_literals
16 from grako.parsing import graken, Parser
17 from grako.util import re, RE_FLAGS, generic_main # noqa
20 __version__ = (2016, 7, 11, 18, 15, 20, 0)
31 class TagsParser(Parser):
42 super(TagsParser, self).__init__(
43 whitespace=whitespace,
45 comments_re=comments_re,
46 eol_comments_re=eol_comments_re,
47 ignorecase=ignorecase,
48 left_recursion=left_recursion,
60 def _expression_(self):
67 self._or_expression_()
68 self._error('no available options')
71 def _or_expression_(self):
77 def _and_expression_(self):
83 def _not_expression_(self):
88 def _parens_expression_(self):
94 def _expression1_(self):
101 self._and_expression_()
102 self._error('no available options')
105 def _expression2_(self):
112 self._not_expression_()
113 self._error('no available options')
116 def _expression3_(self):
119 self._parens_expression_()
122 self._error('no available options')
135 self._error('expecting one of: & && AND and')
148 self._error('expecting one of: OR or | ||')
159 self._error('expecting one of: ! NOT not')
163 self._pattern(r'[a-z][a-z0-9_]+')
166 class TagsSemantics(object):
167 def start(self, ast):
170 def expression(self, ast):
173 def or_expression(self, ast):
176 def and_expression(self, ast):
179 def not_expression(self, ast):
182 def parens_expression(self, ast):
185 def expression1(self, ast):
188 def expression2(self, ast):
191 def expression3(self, ast):
194 def and_op(self, ast):
197 def or_op(self, ast):
200 def not_op(self, ast):
214 eol_comments_re=None,
219 with open(filename) as f:
221 whitespace = whitespace or None
222 parser = TagsParser(parseinfo=False)
228 whitespace=whitespace,
230 ignorecase=ignorecase,
234 if __name__ == '__main__':
236 ast = generic_main(main, TagsParser, name='Tags')
241 print(json.dumps(ast, indent=2))