Compare commits

..

2 Commits

Author SHA1 Message Date
~d6 bd6826c0aa Add mode for modal language 2024-04-09 12:36:26 -04:00
~d6 a3eca840c2 add .gitignore 2024-04-09 12:35:55 -04:00
3 changed files with 50 additions and 1 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
syntax: glob
*.pyc
*.pyo
*~
TAGS
__pycache__

View File

@ -179,7 +179,7 @@ class Application(object):
'awk', 'shell', 'shellmini', 'fstab', 'yacc', 'pipe', 'mbox',
'error', 'lua', 'lily', 'forth', 'ebnf', 'colortest', 'go',
'inform6', 'scala', 'markdown', 'roy', 'twine', 'idris', 'rust',
'bosatsu', 'tal',
'bosatsu', 'tal', 'modal',
)
for name in names:
exec("import mode.%s; mode.%s.install(self)" % (name, name))

43
mode/modal.py Normal file
View File

@ -0,0 +1,43 @@
from mode import Fundamental
from lex import Grammar, PatternRule, RegionRule
class DataGrammar(Grammar):
pass
DataGrammar.rules = [
PatternRule('spaces', ' +'),
RegionRule('sequence', r'\(', DataGrammar, r'\)|$'),
PatternRule('register', r'\?[a-z]'),
PatternRule('word', r'[^() \n]+'),
]
class RuleGrammar(Grammar):
rules = [
PatternRule('spaces', ' +'),
RegionRule('group', r'\(', DataGrammar, r'\)|$'),
PatternRule('register', r'\?[a-z]'),
PatternRule('word', r'[^() \n]+'),
]
class ModalGrammar(Grammar):
rules = [
PatternRule('spaces', ' +'),
PatternRule('eol', r'\n'),
RegionRule('modal.rule', '<>', RuleGrammar, '\n|$'),
PatternRule('modal.lit', r'[^\n]+'),
]
class Modal(Fundamental):
name = 'Modal'
extensions = ['.modal']
grammar = ModalGrammar
colors = {
'modal.lit': ('cyan', 'default'),
'modal.rule.start': ('magenta', 'default'),
'register': ('yellow', 'default'),
'modal.rule.group.start': ('blue', 'default'),
'modal.rule.group.end': ('blue', 'default'),
}
def install(*args):
Modal.install(*args)