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, 9, 18, 10, 4, 5)
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):
75 self._expression_parens_()
78 self._error('no available options')
81 def _expression_parens_(self):
88 self._pattern(r'[a-z][a-z0-9_]+')
101 self._error('expecting one of: & && AND and')
114 self._error('expecting one of: OR or | ||')
125 self._error('expecting one of: ! NOT not')
128 class TagsSemantics(object):
129 def start(self, ast):
132 def expression(self, ast):
135 def expression_parens(self, ast):
141 def and_op(self, ast):
144 def or_op(self, ast):
147 def not_op(self, ast):
158 eol_comments_re=None,
163 with open(filename) as f:
165 whitespace = whitespace or None
166 parser = TagsParser(parseinfo=False)
172 whitespace=whitespace,
174 ignorecase=ignorecase,
178 if __name__ == '__main__':
180 ast = generic_main(main, TagsParser, name='Tags')
185 print(json.dumps(ast, indent=2))