コード例 #1
0
ファイル: parser.py プロジェクト: prajdabre/semescii
 def parse_unary(self):
     token_type = self.stream.current.type
     lineno = self.stream.current.lineno
     if token_type == 'sub':
         next(self.stream)
         node = self.parse_unary()
         return nodes.Neg(node, lineno=lineno)
     if token_type == 'add':
         next(self.stream)
         node = self.parse_unary()
         return nodes.Pos(node, lineno=lineno)
     return self.parse_primary()
コード例 #2
0
ファイル: parser.py プロジェクト: bahar/movie-collection
 def parse_unary(self, with_postfix=True):
     token_type = self.stream.current.type
     lineno = self.stream.current.lineno
     if token_type == 'sub':
         next(self.stream)
         node = nodes.Neg(self.parse_unary(False), lineno=lineno)
     elif token_type == 'add':
         next(self.stream)
         node = nodes.Pos(self.parse_unary(False), lineno=lineno)
     else:
         node = self.parse_primary()
     if with_postfix:
         node = self.parse_postfix(node)
     return node
コード例 #3
0
 def parse_unary(self, with_filter=True):
     token_type = self.stream.current.type
     lineno = self.stream.current.lineno
     if token_type == "sub":
         next(self.stream)
         node = nodes.Neg(self.parse_unary(False), lineno=lineno)
     elif token_type == "add":
         next(self.stream)
         node = nodes.Pos(self.parse_unary(False), lineno=lineno)
     else:
         node = self.parse_primary()
     node = self.parse_postfix(node)
     if with_filter:
         node = self.parse_filter_expr(node)
     return node
コード例 #4
0
ファイル: parser.py プロジェクト: MiniJavaInScala/jFirm
 def parse_unary(self):
     token_type = self.stream.current.type
     lineno = self.stream.current.lineno
     if token_type is 'name' and self.stream.current.value == 'not':
         self.stream.next()
         node = self.parse_unary()
         return nodes.Not(node, lineno=lineno)
     if token_type is 'sub':
         self.stream.next()
         node = self.parse_unary()
         return nodes.Neg(node, lineno=lineno)
     if token_type is 'add':
         self.stream.next()
         node = self.parse_unary()
         return nodes.Pos(node, lineno=lineno)
     return self.parse_primary()