parent
b431523ede
commit
9090a0f44a
|
@ -103,6 +103,8 @@ class Buffer(object):
|
|||
if modename not in self.highlights and w.mode.lexer is not None:
|
||||
self.highlights[modename] = highlight2.Highlighter(w.mode.lexer)
|
||||
self.highlights[modename].highlight(self.lines)
|
||||
#if modename not in self.tabbing and w.mode.tabber is not None:
|
||||
# self.tabbing[modename] =
|
||||
def remove_window(self, w):
|
||||
if w in self.windows:
|
||||
self.windows.remove(w)
|
||||
|
|
|
@ -14,10 +14,10 @@ DATATYPES = {
|
|||
}
|
||||
|
||||
class Argument:
|
||||
def __init__(self, name, typ=type(""), datatype=None, prompt=None, help="",
|
||||
def __init__(self, name, type=type(""), datatype=None, prompt=None, help="",
|
||||
default=default.none, load_default=False):
|
||||
self.name = name
|
||||
self.type = typ
|
||||
self.type = type
|
||||
self.datatype = datatype
|
||||
if prompt is None:
|
||||
self.prompt = "%s: " % (name)
|
||||
|
|
124
mode_python.py
124
mode_python.py
|
@ -1,17 +1,133 @@
|
|||
import commands, os.path, sets, string, sys
|
||||
|
||||
import color, default, mode2, lex2, lex2_python, method, regex, tab_python
|
||||
import ctag_python, completer
|
||||
import color, completer, default, mode2, lex2, method, regex
|
||||
import ctag_python
|
||||
|
||||
from point2 import Point
|
||||
from lex2 import Grammar, ConstantRule, PatternRule, RegionRule, DualRegionRule
|
||||
|
||||
class StringGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule(
|
||||
name=r'octal',
|
||||
pattern=r'\\[0-7]{3}',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'escaped',
|
||||
pattern=r'\\.',
|
||||
),
|
||||
#PatternRule(
|
||||
# name=r'format',
|
||||
# pattern=r'%(?:\([a-zA-Z_]+\))?[-# +]*(?:[0-9]+|\*)?\.?(?:[0-9]+|\*)?[hlL]?[a-zA-Z%]',
|
||||
#),
|
||||
]
|
||||
|
||||
class PythonGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule(
|
||||
name=r'functiondef',
|
||||
pattern=r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'classdef',
|
||||
pattern=r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'reserved',
|
||||
pattern=r'(?:True|None|False|Exception|self)(?![a-zA-Z0-9_])',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'keyword',
|
||||
pattern=r'(?:yield|while|try|return|raise|print|pass|or|not|lambda|is|in|import|if|global|from|for|finally|exec|except|else|elif|del|def|continue|class|break|assert|as|and)(?![a-zA-Z0-9_])',
|
||||
),
|
||||
PatternRule(
|
||||
name=r"builtin",
|
||||
pattern=r'(?<!\.)(?:zip|xrange|vars|unicode|unichr|type|tuple|super|sum|str|staticmethod|sorted|slice|setattr|set|round|repr|reduce|raw_input|range|property|pow|ord|open|oct|object|max|min|map|long|locals|list|len|iter|issubclass|isinstance|int|input|id|hex|hash|hasattr|globals|getattr|frozenset|float|filter|file|execfile|eval|enumerate|divmod|dir|dict|delattr|complex|compile|coerce|cmp|classmethod|chr|callable|bool)(?![a-zA-Z0-9_])',
|
||||
),
|
||||
|
||||
PatternRule(
|
||||
name=r'methodcall',
|
||||
pattern=r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'functioncall',
|
||||
pattern=r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'system_identifier',
|
||||
pattern=r'__[a-zA-Z0-9_]+__',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'private_identifier',
|
||||
pattern=r'__[a-zA-Z0-9_]*',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'hidden_identifier',
|
||||
pattern=r'_[a-zA-Z0-9_]*',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'identifier',
|
||||
pattern=r'[a-zA-Z_][a-zA-Z0-9_]*',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'delimiter',
|
||||
pattern=r'\(|\)|\[|\]|{|}|@|,|:|\.|`|=|;|\+=|-=|\*=|/=|//=|%=|&=|\|=|\^=|>>=|<<=|\*\*=',
|
||||
),
|
||||
PatternRule(
|
||||
name=r"operator",
|
||||
pattern=r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%",
|
||||
),
|
||||
|
||||
PatternRule(
|
||||
name=r"integer",
|
||||
pattern=r"(?<![\.0-9a-zA-Z_])(?:0|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?(?![\.0-9a-zA-Z_])",
|
||||
),
|
||||
PatternRule(
|
||||
name=r"float",
|
||||
pattern=r"(?<![\.0-9a-zA-Z_])(?:[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+)(?![\.0-9a-zA-Z_])",
|
||||
),
|
||||
PatternRule(
|
||||
name=r"imaginary",
|
||||
pattern=r"(?<![\.0-9a-zA-Z_])(?:[0-9]+|(?:[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+)[jJ])(?![\.0-9a-zA-Z_])",
|
||||
),
|
||||
|
||||
RegionRule(
|
||||
name=r'docstring',
|
||||
start=r'^ *(?P<tag>"""|\'\'\')',
|
||||
grammar=Grammar(),
|
||||
end=r'%(tag)s',
|
||||
),
|
||||
RegionRule(
|
||||
name=r'tq_string',
|
||||
start=r'(?P<tag>"""|\'\'\')',
|
||||
grammar=Grammar(),
|
||||
end=r'%(tag)s',
|
||||
),
|
||||
RegionRule(
|
||||
name=r'string',
|
||||
start=r'(?P<tag>"|\')',
|
||||
grammar=StringGrammar(),
|
||||
end=r'%(tag)s',
|
||||
),
|
||||
|
||||
PatternRule(
|
||||
name=r'comment',
|
||||
pattern=r'#.*$',
|
||||
),
|
||||
PatternRule(
|
||||
name=r'continuation',
|
||||
pattern=r'\\$',
|
||||
),
|
||||
]
|
||||
|
||||
class Python(mode2.Fundamental):
|
||||
grammar = PythonGrammar
|
||||
tabber = tab2.Tabber
|
||||
def __init__(self, w):
|
||||
mode2.Fundamental.__init__(self, w)
|
||||
|
||||
self.tag_matching = True
|
||||
#self.tag_matching = False
|
||||
self.grammar = lex2_python.PythonGrammar()
|
||||
self.grammar = PythonGrammar()
|
||||
self.lexer = lex2.Lexer(self.name(), self.grammar)
|
||||
|
||||
self.add_action_and_bindings(PythonCheckSyntax(), ('C-c s',))
|
||||
|
|
Loading…
Reference in New Issue