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

Method parse_statements

tools/inspector_protocol/jinja2/parser.py:149–174  ·  view source on GitHub ↗

Parse multiple statements into a list until one of the end tokens is reached. This is used to parse the body of statements as it also parses template data if appropriate. The parser checks first if the current token is a colon and skips it if there is one. Then it checks

(self, end_tokens, drop_needle=False)

Source from the content-addressed store, hash-verified

147 self._tag_stack.pop()
148
149 def parse_statements(self, end_tokens, drop_needle=False):
150 """Parse multiple statements into a list until one of the end tokens
151 is reached. This is used to parse the body of statements as it also
152 parses template data if appropriate. The parser checks first if the
153 current token is a colon and skips it if there is one. Then it checks
154 for the block end and parses until if one of the `end_tokens` is
155 reached. Per default the active token in the stream at the end of
156 the call is the matched end token. If this is not wanted `drop_needle`
157 can be set to `True` and the end token is removed.
158 """
159 # the first token may be a colon for python compatibility
160 self.stream.skip_if('colon')
161
162 # in the future it would be possible to add whole code sections
163 # by adding some sort of end of statement token and parsing those here.
164 self.stream.expect('block_end')
165 result = self.subparse(end_tokens)
166
167 # we reached the end of the template too early, the subparser
168 # does not check for this, so we do that now
169 if self.stream.current.type == 'eof':
170 self.fail_eof(end_tokens)
171
172 if drop_needle:
173 next(self.stream)
174 return result
175
176 def parse_set(self):
177 """Parse an assign statement."""

Callers 9

parse_setMethod · 0.95
parse_forMethod · 0.95
parse_ifMethod · 0.95
parse_withMethod · 0.95
parse_autoescapeMethod · 0.95
parse_blockMethod · 0.95
parse_call_blockMethod · 0.95
parse_filter_blockMethod · 0.95
parse_macroMethod · 0.95

Calls 5

subparseMethod · 0.95
fail_eofMethod · 0.95
nextFunction · 0.50
skip_ifMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected