parent
36c2114080
commit
66998865eb
|
@ -116,7 +116,7 @@ class Application(object):
|
||||||
'latex', 'insertmini', 'conf', 'haskell', 'erlang',
|
'latex', 'insertmini', 'conf', 'haskell', 'erlang',
|
||||||
'iperl', 'iperlmini', 'ipython', 'ipythonmini', 'awk',
|
'iperl', 'iperlmini', 'ipython', 'ipythonmini', 'awk',
|
||||||
'shell', 'shellmini', 'fstab', 'yacc', 'pipe',
|
'shell', 'shellmini', 'fstab', 'yacc', 'pipe',
|
||||||
'mbox', 'error', 'lua', 'lily'
|
'mbox', 'error', 'lua', 'lily', 'forth'
|
||||||
)
|
)
|
||||||
for name in names:
|
for name in names:
|
||||||
exec("import mode.%s; mode.%s.install(self)" % (name, name))
|
exec("import mode.%s; mode.%s.install(self)" % (name, name))
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
from mode import Fundamental
|
||||||
|
from lex import Grammar, PatternRule, RegionRule, NocasePatternRule, NocaseRegionRule
|
||||||
|
|
||||||
|
class DataGrammar(Grammar):
|
||||||
|
rules = [PatternRule(r'data', r'[^)]+')]
|
||||||
|
|
||||||
|
class ForthGrammar(Grammar):
|
||||||
|
rules = [
|
||||||
|
PatternRule(r'comment', r"\\.*$"),
|
||||||
|
RegionRule(r'comment', r'\(', DataGrammar, r'\)'),
|
||||||
|
NocaseRegionRule(r'comment', r'0 \[if\]', DataGrammar, r'\[(?:endif|then)\]'),
|
||||||
|
PatternRule(r'delimiter', r"[:;\[\]]"),
|
||||||
|
NocasePatternRule(r'keyword', r'(?:variable|value|until|tuck|truth|to|then|test|swap|step|see|rot|roll|recurse|r>|pick|over|mod|m\*|loop|locals|invert|if|hex|here|fsort|fln|fexp|f!|f@|f\+|f-|f\*|f/|execute|endif|else|dup|drop|does>|do|decimal|d!|d@|create|constant|cells|cell|c!|c@|bye|begin|allot|\[(?:if|then|endif)\]|>r|!|@|\+loop|\+|-|\*/mod|\*/|\*|/mod|/)(?=[ \n])'),
|
||||||
|
PatternRule(r'forth_def', r'(?<=:) +[^ ]+'),
|
||||||
|
NocasePatternRule(r'number', r"'[a-z]"),
|
||||||
|
NocasePatternRule(r'number', r'%?-?[0-1]+\.?'),
|
||||||
|
NocasePatternRule(r'number', r'[&#]?-?[0-9]+\.?'),
|
||||||
|
NocasePatternRule(r'number', r"(?:0x|\$)[0-9a-f]+\.?"),
|
||||||
|
NocasePatternRule(r'number', r'[+-]?[0-9]+\.?e?[+-][0-9]+'),
|
||||||
|
PatternRule(r'forth_word', r'[^ ]+'),
|
||||||
|
PatternRule(r'spaces', r' +'),
|
||||||
|
PatternRule(r'eol', r'\n'),
|
||||||
|
]
|
||||||
|
|
||||||
|
class Forth(Fundamental):
|
||||||
|
modename = 'FORTH'
|
||||||
|
extensions = ['.fs']
|
||||||
|
grammar = ForthGrammar
|
||||||
|
commentc = '\\'
|
||||||
|
colors = {
|
||||||
|
'forth_def': ('blue', 'default', 'bold'),
|
||||||
|
'forth_word': ('yellow', 'default', 'bold'),
|
||||||
|
}
|
||||||
|
|
||||||
|
install = Forth.install
|
Loading…
Reference in New Issue