def _token_nud_quoted_identifier(self, token): field = ast.field(token['value']) # You can't have a quoted identifier as a function # name. if self._current_token() == 'lparen': t = self._lookahead_token(0) raise exceptions.ParseError( 0, t['value'], t['type'], 'Quoted identifier not allowed for function names.') return field
def _token_nud_unquoted_identifier(self, token): return ast.field(token['value'])
def test_or_repr(self): self.assert_parsed_ast( 'foo || bar', ast.or_expression(ast.field('foo'), ast.field('bar')))
def test_quoted_subexpression(self): self.assert_parsed_ast( '"foo"."bar"', ast.subexpression([ast.field('foo'), ast.field('bar')]))
def test_dot_syntax(self): self.assert_parsed_ast( 'foo.bar', ast.subexpression([ast.field('foo'), ast.field('bar')]))
def test_field(self): self.assert_parsed_ast('foo', ast.field('foo'))
def test_or_repr(self): self.assert_parsed_ast("foo || bar", ast.or_expression(ast.field("foo"), ast.field("bar")))
def test_quoted_subexpression(self): self.assert_parsed_ast('"foo"."bar"', ast.subexpression([ast.field("foo"), ast.field("bar")]))
def test_dot_syntax(self): self.assert_parsed_ast("foo.bar", ast.subexpression([ast.field("foo"), ast.field("bar")]))
def test_field(self): self.assert_parsed_ast("foo", ast.field("foo"))
def test_or_repr(self): self.assert_parsed_ast('foo || bar', ast.or_expression(ast.field('foo'), ast.field('bar')))
def test_dot_syntax(self): self.assert_parsed_ast('foo.bar', ast.subexpression([ast.field('foo'), ast.field('bar')]))