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

Method parse_statements

deps/v8/third_party/jinja2/parser.py:194–221  ·  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: t.Tuple[str, ...], drop_needle: bool = False
    )

Source from the content-addressed store, hash-verified

192 self._tag_stack.pop()
193
194 def parse_statements(
195 self, end_tokens: t.Tuple[str, ...], drop_needle: bool = False
196 ) -> t.List[nodes.Node]:
197 """Parse multiple statements into a list until one of the end tokens
198 is reached. This is used to parse the body of statements as it also
199 parses template data if appropriate. The parser checks first if the
200 current token is a colon and skips it if there is one. Then it checks
201 for the block end and parses until if one of the `end_tokens` is
202 reached. Per default the active token in the stream at the end of
203 the call is the matched end token. If this is not wanted `drop_needle`
204 can be set to `True` and the end token is removed.
205 """
206 # the first token may be a colon for python compatibility
207 self.stream.skip_if("colon")
208
209 # in the future it would be possible to add whole code sections
210 # by adding some sort of end of statement token and parsing those here.
211 self.stream.expect("block_end")
212 result = self.subparse(end_tokens)
213
214 # we reached the end of the template too early, the subparser
215 # does not check for this, so we do that now
216 if self.stream.current.type == "eof":
217 self.fail_eof(end_tokens)
218
219 if drop_needle:
220 next(self.stream)
221 return result
222
223 def parse_set(self) -> t.Union[nodes.Assign, nodes.AssignBlock]:
224 """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