Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._vendor.pygments.lexer Namespace Reference

Data Structures

class  _inherit
 
class  _PseudoMatch
 
class  _This
 
class  combined
 
class  default
 
class  DelegatingLexer
 
class  ExtendedRegexLexer
 
class  include
 
class  Lexer
 
class  LexerContext
 
class  LexerMeta
 
class  ProfilingRegexLexer
 
class  ProfilingRegexLexerMeta
 
class  RegexLexer
 
class  RegexLexerMeta
 
class  words
 

Functions

 bygroups (*args)
 
 using (_other, **kwargs)
 
 do_insertions (insertions, tokens)
 

Variables

 line_re = re.compile('.*?\n')
 
list _encoding_map
 
 _default_analyse = staticmethod(lambda x: 0.0)
 
 inherit = _inherit()
 
 this = _This()
 

Detailed Description

    pygments.lexer
    ~~~~~~~~~~~~~~

    Base lexer classes.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.

Function Documentation

◆ bygroups()

bygroups ( args)
Callback that yields multiple actions for each group in the match.

Definition at line 365 of file lexer.py.

365def bygroups(*args):
366 """
367 Callback that yields multiple actions for each group in the match.
368 """
369 def callback(lexer, match, ctx=None):
370 for i, action in enumerate(args):
371 if action is None:
372 continue
373 elif type(action) is _TokenType:
374 data = match.group(i + 1)
375 if data:
376 yield match.start(i + 1), action, data
377 else:
378 data = match.group(i + 1)
379 if data is not None:
380 if ctx:
381 ctx.pos = match.start(i + 1)
382 for item in action(lexer,
383 _PseudoMatch(match.start(i + 1), data), ctx):
384 if item:
385 yield item
386 if ctx:
388 return callback
389
390
#define action
Definition ctidh.h:54
for i

References action, and i.

◆ do_insertions()

do_insertions (   insertions,
  tokens 
)
Helper for lexers which must combine the results of several
sublexers.

``insertions`` is a list of ``(index, itokens)`` pairs.
Each ``itokens`` iterable should be inserted at position
``index`` into the token stream given by the ``tokens``
argument.

The result is a combined token stream.

TODO: clean up the code here.

Definition at line 831 of file lexer.py.

831def do_insertions(insertions, tokens):
832 """
833 Helper for lexers which must combine the results of several
834 sublexers.
835
836 ``insertions`` is a list of ``(index, itokens)`` pairs.
837 Each ``itokens`` iterable should be inserted at position
838 ``index`` into the token stream given by the ``tokens``
839 argument.
840
841 The result is a combined token stream.
842
843 TODO: clean up the code here.
844 """
845 insertions = iter(insertions)
846 try:
847 index, itokens = next(insertions)
848 except StopIteration:
849 # no insertions
850 yield from tokens
851 return
852
853 realpos = None
854 insleft = True
855
856 # iterate over the token stream where we want to insert
857 # the tokens from the insertion list.
858 for i, t, v in tokens:
859 # first iteration. store the position of first item
860 if realpos is None:
861 realpos = i
862 oldi = 0
863 while insleft and i + len(v) >= index:
864 tmpval = v[oldi:index - i]
865 if tmpval:
866 yield realpos, t, tmpval
867 realpos += len(tmpval)
868 for it_index, it_token, it_value in itokens:
869 yield realpos, it_token, it_value
870 realpos += len(it_value)
871 oldi = index - i
872 try:
873 index, itokens = next(insertions)
874 except StopIteration:
875 insleft = False
876 break # not strictly necessary
877 if oldi < len(v):
878 yield realpos, t, v[oldi:]
879 realpos += len(v) - oldi
880
881 # leftover tokens
882 while insleft:
883 # no normal tokens, set realpos to zero
884 realpos = realpos or 0
885 for p, t, v in itokens:
886 yield realpos, t, v
887 realpos += len(v)
888 try:
889 index, itokens = next(insertions)
890 except StopIteration:
891 insleft = False
892 break # not strictly necessary
893
894

References i.

◆ using()

using (   _other,
**  kwargs 
)
Callback that processes the match with a different lexer.

The keyword arguments are forwarded to the lexer, except `state` which
is handled separately.

`state` specifies the state that the new lexer will start in, and can
be an enumerable such as ('root', 'inline', 'string') or a simple
string which is assumed to be on top of the root state.

Note: For that to work, `_other` must not be an `ExtendedRegexLexer`.

Definition at line 400 of file lexer.py.

400def using(_other, **kwargs):
401 """
402 Callback that processes the match with a different lexer.
403
404 The keyword arguments are forwarded to the lexer, except `state` which
405 is handled separately.
406
407 `state` specifies the state that the new lexer will start in, and can
408 be an enumerable such as ('root', 'inline', 'string') or a simple
409 string which is assumed to be on top of the root state.
410
411 Note: For that to work, `_other` must not be an `ExtendedRegexLexer`.
412 """
413 gt_kwargs = {}
414 if 'state' in kwargs:
415 s = kwargs.pop('state')
416 if isinstance(s, (list, tuple)):
417 gt_kwargs['stack'] = s
418 else:
419 gt_kwargs['stack'] = ('root', s)
420
421 if _other is this:
422 def callback(lexer, match, ctx=None):
423 # if keyword arguments are given the callback
424 # function has to create a new lexer instance
425 if kwargs:
426 # XXX: cache that somehow
428 lx = lexer.__class__(**kwargs)
429 else:
430 lx = lexer
431 s = match.start()
432 for i, t, v in lx.get_tokens_unprocessed(match.group(), **gt_kwargs):
433 yield i + s, t, v
434 if ctx:
436 else:
437 def callback(lexer, match, ctx=None):
438 # XXX: cache that somehow
440 lx = _other(**kwargs)
441
442 s = match.start()
443 for i, t, v in lx.get_tokens_unprocessed(match.group(), **gt_kwargs):
444 yield i + s, t, v
445 if ctx:
447 return callback
448
449

References i.

Variable Documentation

◆ _default_analyse

_default_analyse = staticmethod(lambda x: 0.0)
protected

Definition at line 34 of file lexer.py.

◆ _encoding_map

list _encoding_map
protected
Initial value:
1= [(b'\xef\xbb\xbf', 'utf-8'),
2 (b'\xff\xfe\0\0', 'utf-32'),
3 (b'\0\0\xfe\xff', 'utf-32be'),
4 (b'\xff\xfe', 'utf-16'),
5 (b'\xfe\xff', 'utf-16be')]

Definition at line 28 of file lexer.py.

◆ inherit

inherit = _inherit()

Definition at line 322 of file lexer.py.

◆ line_re

line_re = re.compile('.*?\n')

Definition at line 26 of file lexer.py.

◆ this

this = _This()

Definition at line 397 of file lexer.py.