scinumtools.dip.pygments package

Submodules

scinumtools.dip.pygments.schema_lexer module

class scinumtools.dip.pygments.schema_lexer.SchemaLexer(*args, **kwds)

Bases: RegexLexer

name = 'DIP'

Full name of the lexer, in human-readable form

tokens = {'reference': [('[^}]+', ('DIP', 'Reference')), ('{', ('DIP', 'Reference'), '#push'), ('}\\[', ('DIP', 'Reference'), 'reference_slice'), ('}', ('DIP', 'Reference'), '#pop')], 'reference_slice': [('[^\\]]+', ('DIP', 'Slice')), (',', ('DIP', 'Reference')), ('\\]', ('DIP', 'Reference'), '#pop:2')], 'root': [('<indent>', ('DIP', 'Indent')), ('<name>', ('DIP', 'Name')), ('<type>', ('DIP', 'Type')), ('<unit>', ('DIP', 'Unit')), ('<value>', ('DIP', 'String')), ('<path>', ('DIP', 'String')), ('\\.\\.\\.', ('DIP', 'Text')), ('(\\()("""\\n|"|\\\')(<expression>)(\\n"""|"|\\\')(\\))', <function bygroups.<locals>.callback>), ('(\\()(<function>)(\\))', <function bygroups.<locals>.callback>), ('<[^ ]', ('DIP', 'Tag'), 'tag'), ('{', ('DIP', 'Reference'), 'reference'), ('!(options|format|condition|constant|tags|description)', ('DIP', 'Keyword')), ('\\$(source|unit)', ('DIP', 'Keyword')), ('\\@(case|else|end)', ('DIP', 'Keyword')), ('( |=|<|>|\\.\\*|\\*)', ('DIP', 'Text')), ('#[^\\n]*', ('DIP', 'Comment')), ('[ ]*\\n', ('DIP', 'Text'))], 'tag': [('[a-zA-Z0-9_-]+', ('DIP', 'Tag')), ('>', ('DIP', 'Tag'), '#pop')]}

At all time there is a stack of states. Initially, the stack contains a single state ‘root’. The top of the stack is called “the current state”.

Dict of {'state': [(regex, tokentype, new_state), ...], ...}

new_state can be omitted to signify no state transition. If new_state is a string, it is pushed on the stack. This ensure the new current state is new_state. If new_state is a tuple of strings, all of those strings are pushed on the stack and the current state will be the last element of the list. new_state can also be combined('state1', 'state2', ...) to signify a new, anonymous state combined from the rules of two or more existing ones. Furthermore, it can be ‘#pop’ to signify going back one step in the state stack, or ‘#push’ to push the current state on the stack again. Note that if you push while in a combined state, the combined state itself is pushed, and not only the state in which the rule is defined.

The tuple can also be replaced with include('state'), in which case the rules from the state named by the string are included in the current one.

scinumtools.dip.pygments.style_lexer module

class scinumtools.dip.pygments.style_lexer.StyleLexer

Bases: Style

styles = {(): '', ('Comment',): 'italic #3D7B7B', ('Comment', 'Hashbang'): '', ('Comment', 'Multiline'): '', ('Comment', 'Preproc'): 'noitalic #9C6500', ('Comment', 'PreprocFile'): '', ('Comment', 'Single'): '', ('Comment', 'Special'): '', ('DIP', 'Boolean'): 'bold #0D47A1', ('DIP', 'Comment'): 'italic #FB8C00', ('DIP', 'Dimension'): '#9E9E9E', ('DIP', 'Expression'): '#8D6E63', ('DIP', 'Indent'): '#BDBDBD', ('DIP', 'Keyword'): '#757575', ('DIP', 'Name'): 'bold #616161', ('DIP', 'Number'): '#B71C1C', ('DIP', 'Reference'): '#E64A19', ('DIP', 'Slice'): '#FF8A65', ('DIP', 'String'): '#558B2F', ('DIP', 'Tag'): '#0097A7', ('DIP', 'Type'): '#616161', ('DIP', 'Unit'): '#607D8B', ('Error',): 'border:#FF0000', ('Escape',): '', ('Generic',): '', ('Generic', 'Deleted'): '#A00000', ('Generic', 'Emph'): 'italic', ('Generic', 'EmphStrong'): 'bold italic', ('Generic', 'Error'): '#E40000', ('Generic', 'Heading'): 'bold #000080', ('Generic', 'Inserted'): '#008400', ('Generic', 'Output'): '#717171', ('Generic', 'Prompt'): 'bold #000080', ('Generic', 'Strong'): 'bold', ('Generic', 'Subheading'): 'bold #800080', ('Generic', 'Traceback'): '#04D', ('Keyword',): 'bold #008000', ('Keyword', 'Constant'): '', ('Keyword', 'Declaration'): '', ('Keyword', 'Namespace'): '', ('Keyword', 'Pseudo'): 'nobold', ('Keyword', 'Reserved'): '', ('Keyword', 'Type'): 'nobold #B00040', ('Literal',): '', ('Literal', 'Date'): '', ('Literal', 'Number'): '#666666', ('Literal', 'Number', 'Bin'): '', ('Literal', 'Number', 'Float'): '', ('Literal', 'Number', 'Hex'): '', ('Literal', 'Number', 'Integer'): '', ('Literal', 'Number', 'Integer', 'Long'): '', ('Literal', 'Number', 'Oct'): '', ('Literal', 'String'): '#BA2121', ('Literal', 'String', 'Affix'): '', ('Literal', 'String', 'Backtick'): '', ('Literal', 'String', 'Char'): '', ('Literal', 'String', 'Delimiter'): '', ('Literal', 'String', 'Doc'): 'italic', ('Literal', 'String', 'Double'): '', ('Literal', 'String', 'Escape'): 'bold #AA5D1F', ('Literal', 'String', 'Heredoc'): '', ('Literal', 'String', 'Interpol'): 'bold #A45A77', ('Literal', 'String', 'Other'): '#008000', ('Literal', 'String', 'Regex'): '#A45A77', ('Literal', 'String', 'Single'): '', ('Literal', 'String', 'Symbol'): '#19177C', ('Name',): '', ('Name', 'Attribute'): '#687822', ('Name', 'Builtin'): '#008000', ('Name', 'Builtin', 'Pseudo'): '', ('Name', 'Class'): 'bold #0000FF', ('Name', 'Constant'): '#880000', ('Name', 'Decorator'): '#AA22FF', ('Name', 'Entity'): 'bold #717171', ('Name', 'Exception'): 'bold #CB3F38', ('Name', 'Function'): '#0000FF', ('Name', 'Function', 'Magic'): '', ('Name', 'Label'): '#767600', ('Name', 'Namespace'): 'bold #0000FF', ('Name', 'Other'): '', ('Name', 'Property'): '', ('Name', 'Tag'): 'bold #008000', ('Name', 'Variable'): '#19177C', ('Name', 'Variable', 'Class'): '', ('Name', 'Variable', 'Global'): '', ('Name', 'Variable', 'Instance'): '', ('Name', 'Variable', 'Magic'): '', ('Operator',): '#666666', ('Operator', 'Word'): 'bold #AA22FF', ('Other',): '', ('Punctuation',): '', ('Punctuation', 'Marker'): '', ('Text',): '', ('Text', 'Whitespace'): '', ('Whitespace',): '#bbbbbb'}

Style definitions for individual token types.

scinumtools.dip.pygments.style_lexer.pygments_monkeypatch_style(mod_name, cls)

scinumtools.dip.pygments.syntax_lexer module

class scinumtools.dip.pygments.syntax_lexer.SyntaxLexer(*args, **kwds)

Bases: RegexLexer

name = 'DIP'

Full name of the lexer, in human-readable form

tokens = {'expr_double': [('\\\\({)', <function bygroups.<locals>.callback>), ('{', ('DIP', 'Reference'), 'reference_expr'), ('[^"\\\\{]+', ('DIP', 'Expression')), ('\\\\"', ('DIP', 'Expression')), ('\\\\[^"]', ('DIP', 'Expression')), ('(")(\\))', <function bygroups.<locals>.callback>, 'unit')], 'expr_single': [('\\\\({)', <function bygroups.<locals>.callback>), ('{', ('DIP', 'Reference'), 'reference_expr'), ("[^'\\\\{]+", ('DIP', 'Expression')), ("\\\\'", ('DIP', 'Expression')), ("\\\\[^']", ('DIP', 'Expression')), ("(')(\\))", <function bygroups.<locals>.callback>, 'unit')], 'expr_triple': [('\\\\({)', <function bygroups.<locals>.callback>), ('{', ('DIP', 'Reference'), 'reference_expr'), ('[^"\\\\{]+', ('DIP', 'Expression')), ('\\\\"', ('DIP', 'Expression')), ('\\\\[^"]', ('DIP', 'Expression')), ('"[^"]', ('DIP', 'Expression')), ('""[^"]', ('DIP', 'Expression')), ('(""")(\\))', <function bygroups.<locals>.callback>, 'unit')], 'node_type': [('([ ]*)({)', <function bygroups.<locals>.callback>, 'reference'), ('([ ]*)(bool|[u]?int[0-9]*|float[0-9]*|str|table)(\\[)', <function bygroups.<locals>.callback>, 'type_dim'), ('([ ]*)(bool|[u]?int[0-9]*|float[0-9]*|str|table)([ ]+=)', <function bygroups.<locals>.callback>, 'node_value'), ('([ ]*)(bool|[u]?int[0-9]*|float[0-9]*|str|table)', <function bygroups.<locals>.callback>, 'unit'), ('([ ]*)(bool|[u]?int[0-9]*|float[0-9]*|str|table)', <function bygroups.<locals>.callback>, '#pop'), (' ', ('DIP', 'Text'), '#pop')], 'node_value': [('([ ]*)(true|false)', <function bygroups.<locals>.callback>), ('([ ]*)(-[0-9.]+|[0-9.]+)(e-[0-9]+|e[0-9]+|)([ ]+[^#\\n ]+|)', <function bygroups.<locals>.callback>), ("([ ]*)(')", <function bygroups.<locals>.callback>, 'str_single'), ('([ ]*)(""")', <function bygroups.<locals>.callback>, 'str_triple'), ('([ ]*)(")', <function bygroups.<locals>.callback>, 'str_double'), ('([ ]*\\()([a-zA-Z0-9_-]+)(\\))', <function bygroups.<locals>.callback>, 'unit'), ("([ ]*\\()(')", <function bygroups.<locals>.callback>, 'expr_single'), ('([ ]*\\()(""")', <function bygroups.<locals>.callback>, 'expr_triple'), ('([ ]*\\()(")', <function bygroups.<locals>.callback>, 'expr_double'), ('([ ]*)({)', <function bygroups.<locals>.callback>, 'reference'), ('([ ]*)(\\[)', <function bygroups.<locals>.callback>, '#push'), ('(,)', ('DIP', 'Text')), ('(\\])([ ]+[^#\\n ]*)', <function bygroups.<locals>.callback>, '#pop:4'), ('(\\])', ('DIP', 'Text'), '#pop'), ('([ ]*)([^#\\n ]+)', <function bygroups.<locals>.callback>), ('[ ]', ('DIP', 'Text'), '#pop:4')], 'reference': [('{', ('DIP', 'Reference'), '#push'), ('[^{}]+', ('DIP', 'Reference')), ('}\\[', ('DIP', 'Reference'), 'reference_slice'), ('}', ('DIP', 'Reference'), 'unit')], 'reference_expr': [('{', ('DIP', 'Reference'), '#push'), ('[^{}]+', ('DIP', 'Reference')), ('}\\[', ('DIP', 'Reference'), 'reference_slice'), ('(}:)([0-9sdef.]+)', <function bygroups.<locals>.callback>, '#pop'), ('}', ('DIP', 'Reference'), '#pop')], 'reference_slice': [('[0-9.:]+', ('DIP', 'Slice')), (',', ('DIP', 'Reference')), ('\\]}', ('DIP', 'Reference'), '#pop:3'), ('(\\]:)([0-9sdef.]+)', <function bygroups.<locals>.callback>, '#pop:2'), ('\\]', ('DIP', 'Reference'), 'unit')], 'root': [('([ ]*)(#[^\\n]*|)(\\n)', <function bygroups.<locals>.callback>), ('([ ]*)(\\$source|\\$unit)([ ]+)({)', <function bygroups.<locals>.callback>, 'reference'), ('([ ]*)(\\$source|\\$unit)([ ]+)([a-zA-Z0-9-_]+)([ ]+=)', <function bygroups.<locals>.callback>, 'node_value'), ('[ ]*\\@case', ('DIP', 'Keyword'), 'node_value'), ('[ ]*\\@(else|end)', ('DIP', 'Keyword')), ('[ ]*!(options|format|condition|constant|tags|description)', ('DIP', 'Keyword'), 'node_value'), ('[ ]*!(desc)', ('DIP', 'Keyword'), 'node_value'), ('^([ ]*)(=)', <function bygroups.<locals>.callback>, 'node_value'), ('^([ ]*)([a-zA-Z0-9-_.]+)([ ]+=)', <function bygroups.<locals>.callback>, 'node_value'), ('^([ ]*)([a-zA-Z0-9-_.]+)', <function bygroups.<locals>.callback>, 'node_type'), ('([ ]*)({)', <function bygroups.<locals>.callback>, 'reference')], 'str_double': [('[^"\\\\]+', ('DIP', 'String')), ('\\\\"', ('DIP', 'String')), ('\\\\[^"]', ('DIP', 'String')), ('(")(,)', <function bygroups.<locals>.callback>, '#pop'), ('(")(\\])', <function bygroups.<locals>.callback>, '#pop:2'), ('"', ('DIP', 'String'), 'unit')], 'str_single': [("[^'\\\\]+", ('DIP', 'String')), ("\\\\'", ('DIP', 'String')), ("\\\\[^']", ('DIP', 'String')), ("(')(,)", <function bygroups.<locals>.callback>, '#pop'), ("(')(\\])", <function bygroups.<locals>.callback>, '#pop:2'), ("(')", ('DIP', 'String'), 'unit')], 'str_triple': [('[^"\\\\]+', ('DIP', 'String')), ('\\\\"', ('DIP', 'String')), ('\\\\[^"]', ('DIP', 'String')), ('"[^"]', ('DIP', 'String')), ('""[^"]', ('DIP', 'String')), ('(""")(,)', <function bygroups.<locals>.callback>, '#pop'), ('(""")(\\])', <function bygroups.<locals>.callback>, '#pop:2'), ('"""', ('DIP', 'String'), 'unit')], 'type_dim': [('[0-9.:]+', ('DIP', 'Dimension')), (',', ('DIP', 'Type')), ('(\\])([ ]+=)', <function bygroups.<locals>.callback>, 'node_value'), ('\\]', ('DIP', 'Type'), 'unit'), (' ', ('DIP', 'Text'), '#pop:2')], 'unit': [('([ ]+[^=#\\n ]+|)', ('DIP', 'Unit'), '#pop:6')]}

At all time there is a stack of states. Initially, the stack contains a single state ‘root’. The top of the stack is called “the current state”.

Dict of {'state': [(regex, tokentype, new_state), ...], ...}

new_state can be omitted to signify no state transition. If new_state is a string, it is pushed on the stack. This ensure the new current state is new_state. If new_state is a tuple of strings, all of those strings are pushed on the stack and the current state will be the last element of the list. new_state can also be combined('state1', 'state2', ...) to signify a new, anonymous state combined from the rules of two or more existing ones. Furthermore, it can be ‘#pop’ to signify going back one step in the state stack, or ‘#push’ to push the current state on the stack again. Note that if you push while in a combined state, the combined state itself is pushed, and not only the state in which the rule is defined.

The tuple can also be replaced with include('state'), in which case the rules from the state named by the string are included in the current one.

Module contents