MCPcopy Index your code
hub / github.com/nodejs/node / parse_primary

Method parse_primary

tools/inspector_protocol/jinja2/parser.py:552–584  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers 3

parse_assign_targetMethod · 0.95
parse_unaryMethod · 0.95
parse_testMethod · 0.95

Calls 10

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

Tested by

no test coverage detected