parent
df66581780
commit
fc016f1716
|
@ -117,7 +117,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', 'forth',
|
'mbox', 'error', 'lua', 'lily', 'forth', 'ebnf',
|
||||||
)
|
)
|
||||||
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,16 @@
|
||||||
|
(* a simple program in EBNF - Wikipedia *)
|
||||||
|
program = 'PROGRAM' , white space , identifier , white space ,
|
||||||
|
'BEGIN' , white space ,
|
||||||
|
{ assignment , ";" , white space } ,
|
||||||
|
'END.' ;
|
||||||
|
identifier = alphabetic character , { alphabetic character | digit } ;
|
||||||
|
number = [ "-" ] , digit , { digit } ;
|
||||||
|
string = '"' , { all characters - '"' } , '"' ;
|
||||||
|
assignment = identifier , ":=" , ( number | identifier | string ) ;
|
||||||
|
alphabetic character = "A" | "B" | "C" | "D" | "E" | "F" | "G"
|
||||||
|
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
|
||||||
|
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
|
||||||
|
| "V" | "W" | "X" | "Y" | "Z" ;
|
||||||
|
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
|
||||||
|
white space = ? white space characters ? ;
|
||||||
|
all characters = ? all visible characters ? ;
|
|
@ -0,0 +1,35 @@
|
||||||
|
from mode import Fundamental
|
||||||
|
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
||||||
|
from mode.python import StringGrammar1, StringGrammar2, StringGrammar3, StringGrammar4
|
||||||
|
|
||||||
|
class CommentGrammar(Grammar):
|
||||||
|
rules = [PatternRule('data', r'(?:[^\*]|\*(?!\)))+')]
|
||||||
|
class SequenceGrammar(Grammar):
|
||||||
|
rules = [PatternRule('data', r'(?:\\.|[^?])+')]
|
||||||
|
|
||||||
|
class EbnfGrammar(Grammar):
|
||||||
|
rules = [
|
||||||
|
PatternRule('spaces', ' +'),
|
||||||
|
PatternRule('eol', r'\n'),
|
||||||
|
RegionRule('string', "'", StringGrammar1, "'"),
|
||||||
|
RegionRule('string', '"', StringGrammar2, '"'),
|
||||||
|
RegionRule('ebnf_sequence', r'\?', SequenceGrammar, r'\?'),
|
||||||
|
RegionRule('comment', r'\(\*', CommentGrammar, r'\*\)'),
|
||||||
|
PatternRule('delimiter', '[=,;|\[\]{}\(\)-]'),
|
||||||
|
PatternRule('ebnf_nonterminal', r'[a-zA-Z_][-a-zA-Z0-9_ ]*[a-zA-Z0-9_]'),
|
||||||
|
PatternRule('ebnf_nonterminal', r'[a-zA-Z_]'),
|
||||||
|
]
|
||||||
|
|
||||||
|
class Ebnf(Fundamental):
|
||||||
|
name = 'ebnf'
|
||||||
|
extensions = ['.ebnf']
|
||||||
|
grammar = EbnfGrammar
|
||||||
|
colors = {
|
||||||
|
'ebnf_sequence.start': ('magenta', 'default', 'bold'),
|
||||||
|
'ebnf_sequence.data': ('magenta', 'default', 'bold'),
|
||||||
|
'ebnf_sequence.null': ('magenta', 'default', 'bold'),
|
||||||
|
'ebnf_sequence.end': ('magenta', 'default', 'bold'),
|
||||||
|
'ebnf_nonterminal': ('cyan', 'default', 'bold'),
|
||||||
|
}
|
||||||
|
|
||||||
|
install = Ebnf.install
|
|
@ -1,4 +1,4 @@
|
||||||
import color, mode
|
from mode import Fundamental
|
||||||
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
||||||
from mode.python import StringGrammar1, StringGrammar2, StringGrammar3, StringGrammar4
|
from mode.python import StringGrammar1, StringGrammar2, StringGrammar3, StringGrammar4
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class NasmGrammar(Grammar):
|
||||||
PatternRule('comment', ';.*$'),
|
PatternRule('comment', ';.*$'),
|
||||||
]
|
]
|
||||||
|
|
||||||
class Nasm(mode.Fundamental):
|
class Nasm(Fundamental):
|
||||||
name = 'nasm'
|
name = 'nasm'
|
||||||
extensions = ['.s']
|
extensions = ['.s']
|
||||||
grammar = NasmGrammar
|
grammar = NasmGrammar
|
||||||
|
|
Loading…
Reference in New Issue