MCPcopy Index your code
hub / github.com/pyload/pyload / parse_primary

Method parse_primary

module/lib/jinja2/parser.py:544–576  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

542 return node
543
544 def parse_primary(self):
545 token = self.stream.current
546 if token.type == 'name':
547 if token.value in ('true', 'false', 'True', 'False'):
548 node = nodes.Const(token.value in ('true', 'True'),
549 lineno=token.lineno)
550 elif token.value in ('none', 'None'):
551 node = nodes.Const(None, lineno=token.lineno)
552 else:
553 node = nodes.Name(token.value, 'load', lineno=token.lineno)
554 next(self.stream)
555 elif token.type == 'string':
556 next(self.stream)
557 buf = [token.value]
558 lineno = token.lineno
559 while self.stream.current.type == 'string':
560 buf.append(self.stream.current.value)
561 next(self.stream)
562 node = nodes.Const(''.join(buf), lineno=lineno)
563 elif token.type in ('integer', 'float'):
564 next(self.stream)
565 node = nodes.Const(token.value, lineno=token.lineno)
566 elif token.type == 'lparen':
567 next(self.stream)
568 node = self.parse_tuple(explicit_parentheses=True)
569 self.stream.expect('rparen')
570 elif token.type == 'lbracket':
571 node = self.parse_list()
572 elif token.type == 'lbrace':
573 node = self.parse_dict()
574 else:
575 self.fail("unexpected '%s'" % describe_token(token), token.lineno)
576 return node
577
578 def parse_tuple(self, simplified=False, with_condexpr=True,
579 extra_end_rules=None, explicit_parentheses=False):

Callers 2

parse_assign_targetMethod · 0.95
parse_unaryMethod · 0.95

Calls 9

parse_tupleMethod · 0.95
parse_listMethod · 0.95
parse_dictMethod · 0.95
failMethod · 0.95
nextFunction · 0.90
describe_tokenFunction · 0.90
joinMethod · 0.80
expectMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected