branch : pmacs2
This commit is contained in:
moculus 2008-10-01 22:10:11 +00:00
parent 3d79850575
commit 60187fc088
1 changed files with 13 additions and 3 deletions

View File

@ -3,10 +3,18 @@ import color, mode, tab
from lex import Grammar, PatternRule, RegionRule from lex import Grammar, PatternRule, RegionRule
from mode.python import StringGrammar2 from mode.python import StringGrammar2
class RegexGrammar(Grammar):
rules = [
PatternRule(r'escaped', r'\\.'),
PatternRule(r'data', r'[^\\/]+'),
]
class AwkGrammar(Grammar): class AwkGrammar(Grammar):
rules = [ rules = [
PatternRule(r'comment', '#.*\n$'), PatternRule(r'comment', r'#.*\n$'),
PatternRule(r'awk_global_var', r'(?:TEXTDOMAIN|SUBSEP|RLENGTH|RSTART|RT|RS|PROCINFO|ORS|OFS|OFMT|NR|NF|LINT|IGNORECASE|FS|FNR|FILENAME|FIELDWIDTHS|ERRNO|ENVIRON|CONVFMT|BINMODE|ARGV|ARGIND|ARGC)(?![a-zA-Z0-9_])'), PatternRule(r'spaces', r' +'),
RegionRule(r'regex', r'/(?! )', RegexGrammar, r'/'),
PatternRule(r'awk_global', r'(?:TEXTDOMAIN|SUBSEP|RLENGTH|RSTART|RT|RS|PROCINFO|ORS|OFS|OFMT|NR|NF|LINT|IGNORECASE|FS|FNR|FILENAME|FIELDWIDTHS|ERRNO|ENVIRON|CONVFMT|BINMODE|ARGV|ARGIND|ARGC)(?![a-zA-Z0-9_])'),
PatternRule(r'delimiter', r'(?:[\{\}()\[\]?:;,\$]|=(?!=)|\+=|-=|\*=|/=|\%=|\^=)'), PatternRule(r'delimiter', r'(?:[\{\}()\[\]?:;,\$]|=(?!=)|\+=|-=|\*=|/=|\%=|\^=)'),
PatternRule(r'keyword', r'(?:if|else|while|do|for|break|continue|delete|exit|close|getline|nextfile|next|printf|print|system|fflush|atan2|cos|exp|int|log|rand|sin|sqrt|srand|asorti|asort|gensub|gsub|index|length|match|split|sprintf|strtonum|substr|sub|tolower|toupper|mktime|strftime|systime|and|compl|lshift|or|xor|rshift|bindtextdomain|dcgettext|dcngettext|function|extension)(?![a-zA-Z0-9_])'), PatternRule(r'keyword', r'(?:if|else|while|do|for|break|continue|delete|exit|close|getline|nextfile|next|printf|print|system|fflush|atan2|cos|exp|int|log|rand|sin|sqrt|srand|asorti|asort|gensub|gsub|index|length|match|split|sprintf|strtonum|substr|sub|tolower|toupper|mktime|strftime|systime|and|compl|lshift|or|xor|rshift|bindtextdomain|dcgettext|dcngettext|function|extension)(?![a-zA-Z0-9_])'),
PatternRule(r'unop', r'!(?![=~])|--|\+\+'), PatternRule(r'unop', r'!(?![=~])|--|\+\+'),
@ -14,6 +22,8 @@ class AwkGrammar(Grammar):
RegionRule(r'string', r'"', StringGrammar2, r'"'), RegionRule(r'string', r'"', StringGrammar2, r'"'),
PatternRule(r'function', r'[a-zA-Z_][a-zA-Z0-9_]*(?=\()'), PatternRule(r'function', r'[a-zA-Z_][a-zA-Z0-9_]*(?=\()'),
PatternRule(r'identifier', r'[a-zA-Z_][a-zA-Z0-9_]*'), PatternRule(r'identifier', r'[a-zA-Z_][a-zA-Z0-9_]*'),
PatternRule(r'cont', r'\\(?=\n)'),
PatternRule(r'eol', r'\n'),
] ]
class Awk(mode.Fundamental): class Awk(mode.Fundamental):
@ -21,7 +31,7 @@ class Awk(mode.Fundamental):
extensions = ['.awk'] extensions = ['.awk']
grammar = AwkGrammar grammar = AwkGrammar
colors = { colors = {
'awk_global_var': ('cyan', 'default', 'bold'), 'awk_global': ('cyan', 'default', 'bold'),
} }
install = Awk.install install = Awk.install