]> git.phdru.name Git - phdru.name/cgi-bin/blog-ru/search-tags.git/blob - parser/build_ast.py
Change grammar to support priority of operation
[phdru.name/cgi-bin/blog-ru/search-tags.git] / parser / build_ast.py
1
2 from parser import TagsSemantics as _TagsSemantics
3
4 class TagsSemantics(_TagsSemantics):
5     def or_expression(self, ast):
6         return ('OR', ast[0], ast[2])
7
8     def and_expression(self, ast):
9         return ('AND', ast[0], ast[2])
10
11     def not_expression(self, ast):
12         return ('NOT', ast[1])
13
14     def parens_expression(self, ast):
15         return ('PARENS', ast[1])
16
17     def name(self, ast):
18         return ('NAME', str(ast))
19
20     def and_op(self, ast):
21         return 'AND'
22
23     def or_op(self, ast):
24         return 'OR'
25
26     def not_op(self, ast):
27         return 'NOT'