MCPcopy Create free account
hub / github.com/nodejs/node / lex

Method lex

deps/v8/third_party/jinja2/environment.py:619–638  ·  view source on GitHub ↗

Lex the given sourcecode and return a generator that yields tokens as tuples in the form ``(lineno, token_type, value)``. This can be useful for :ref:`extension development ` and debugging templates. This does not perform preprocessing. If you wa

(
        self,
        source: str,
        name: t.Optional[str] = None,
        filename: t.Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

617 return Parser(self, source, name, filename).parse()
618
619 def lex(
620 self,
621 source: str,
622 name: t.Optional[str] = None,
623 filename: t.Optional[str] = None,
624 ) -> t.Iterator[t.Tuple[int, str, str]]:
625 """Lex the given sourcecode and return a generator that yields
626 tokens as tuples in the form ``(lineno, token_type, value)``.
627 This can be useful for :ref:`extension development <writing-extensions>`
628 and debugging templates.
629
630 This does not perform preprocessing. If you want the preprocessing
631 of the extensions to be applied you have to filter source through
632 the :meth:`preprocess` method.
633 """
634 source = str(source)
635 try:
636 return self.lexer.tokeniter(source, name, filename)
637 except TemplateSyntaxError:
638 self.handle_exception(source=source)
639
640 def preprocess(
641 self,

Callers 1

babel_extractFunction · 0.95

Calls 3

handle_exceptionMethod · 0.95
strFunction · 0.85
tokeniterMethod · 0.45

Tested by

no test coverage detected