Class: CodeRay::Scanners::Python
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/coderay-1.1.3/lib/coderay/scanners/python.rb
Overview
Scanner for Python. Supports Python 3.
Based on pygments’ PythonLexer, see dev.pocoo.org/projects/pygments/browser/pygments/lexers/agile.py.
Constant Summary collapse
- KEYWORDS =
[ 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield', 'nonlocal', # new in Python 3 ]
- OLD_KEYWORDS =
:nodoc:
[ 'exec', 'print', # gone in Python 3 ]
- PREDEFINED_METHODS_AND_TYPES =
:nodoc:
%w[ __import__ abs all any apply basestring bin bool buffer bytearray bytes callable chr classmethod cmp coerce compile complex delattr dict dir divmod enumerate eval execfile exit file filter float frozenset getattr globals hasattr hash hex id input int intern isinstance issubclass iter len list locals long map max min next object oct open ord pow property range raw_input reduce reload repr reversed round set setattr slice sorted staticmethod str sum super tuple type unichr unicode vars xrange zip ]
- PREDEFINED_EXCEPTIONS =
:nodoc:
%w[ ArithmeticError AssertionError AttributeError BaseException DeprecationWarning EOFError EnvironmentError Exception FloatingPointError FutureWarning GeneratorExit IOError ImportError ImportWarning IndentationError IndexError KeyError KeyboardInterrupt LookupError MemoryError NameError NotImplemented NotImplementedError OSError OverflowError OverflowWarning PendingDeprecationWarning ReferenceError RuntimeError RuntimeWarning StandardError StopIteration SyntaxError SyntaxWarning SystemError SystemExit TabError TypeError UnboundLocalError UnicodeDecodeError UnicodeEncodeError UnicodeError UnicodeTranslateError UnicodeWarning UserWarning ValueError Warning ZeroDivisionError ]
- PREDEFINED_VARIABLES_AND_CONSTANTS =
:nodoc:
[ 'False', 'True', 'None', # "keywords" since Python 3 'self', 'Ellipsis', 'NotImplemented', ]
- IDENT_KIND =
:nodoc:
WordList.new(:ident). add(KEYWORDS, :keyword). add(OLD_KEYWORDS, :old_keyword). add(PREDEFINED_METHODS_AND_TYPES, :predefined). add(PREDEFINED_VARIABLES_AND_CONSTANTS, :predefined_constant). add(PREDEFINED_EXCEPTIONS, :exception)
- NAME =
:nodoc:
/ [[:alpha:]_] \w* /x
- ESCAPE =
:nodoc:
/ [abfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
- UNICODE_ESCAPE =
:nodoc:
/ u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} | N\{[-\w ]+\} /x
- OPERATOR =
/ \.\.\. | # ellipsis \.(?!\d) | # dot but not decimal point [,;:()\[\]{}] | # simple delimiters \/\/=? | \*\*=? | # special math [-+*\/%&|^]=? | # ordinary math and binary logic [~`] | # binary complement and inspection <<=? | >>=? | [<>=]=? | != # comparison and assignment /x
- STRING_DELIMITER_REGEXP =
:nodoc:
Hash.new { |h, delimiter| h[delimiter] = Regexp.union delimiter # :nodoc: }
- STRING_CONTENT_REGEXP =
Hash.new { |h, delimiter| h[delimiter] = / [^\\\n]+? (?= \\ | $ | #{Regexp.escape(delimiter)} ) /x # :nodoc: }
- DEF_NEW_STATE =
WordList.new(:initial). add(%w(def), :def_expected). add(%w(import from), :include_expected). add(%w(class), :class_expected)
- DESCRIPTOR =
/ #{NAME} (?: \. #{NAME} )* | \* /x
- DOCSTRING_COMING =
:nodoc:
/ [ \t]* u?r? ("""|''') /x
Constants inherited from Scanner
Scanner::DEFAULT_OPTIONS, Scanner::KINDS_NOT_LOC, Scanner::ScanError
Instance Attribute Summary
Attributes inherited from Scanner
Attributes included from Plugin
Method Summary
Methods inherited from Scanner
#binary_string, #column, #each, encoding, file_extension, #file_extension, #initialize, #lang, lang, #line, normalize, #reset, #string=, #tokenize, #tokens
Methods included from Plugin
#aliases, #plugin_host, #register_for, #title
Methods included from Enumerable
#as_json, #compact_blank, #exclude?, #excluding, #in_order_of, #including, #index_by, #index_with, #many?, #maximum, #minimum, #pick, #pluck, #sole, #sum
Constructor Details
This class inherits a constructor from CodeRay::Scanners::Scanner