2013-06-12 01:29:36 +00:00
|
|
|
from pygments.lexer import RegexLexer, bygroups
|
|
|
|
from pygments.token import *
|
|
|
|
|
|
|
|
class DataSpecLexer(RegexLexer):
|
|
|
|
name = 'DataSpec'
|
|
|
|
aliases = ['dataspec']
|
|
|
|
filenames = []
|
|
|
|
|
|
|
|
tokens = {
|
|
|
|
'root': [
|
|
|
|
(r'(\s*)(\+-)', bygroups(Text, Text), 'boundary'),
|
|
|
|
(r'(\s+)([\+|])', bygroups(Text, Text), 'content'),
|
2013-06-12 03:21:09 +00:00
|
|
|
(r'(\s*)(~)', bygroups(Text, Generic.Strong), 'content'),
|
2014-01-08 07:01:41 +00:00
|
|
|
(r'(\s*)([\w=;]+)(\s[\w=;]+)*(\s)(::)(\s)', bygroups(Text, Name.Tag, Name.Tag, Text, Operator, Text)),
|
|
|
|
(r'(\s*)`((?:[A-Z][a-z]+)(?:[A-Z][a-z]*)*)`', bygroups(Text, Name.Class)),
|
2013-06-12 02:27:14 +00:00
|
|
|
(r'(\s*)([A-Z]{2,})', bygroups(Text, Name.Constant)),
|
|
|
|
(r'(\s*)([\[\]])', bygroups(Text, Punctuation)),
|
|
|
|
(r'(\s*)(\$\w+)', bygroups(Text, Name.Tag)),
|
|
|
|
(r'(\s*)([0-9]+)(\+)?', bygroups(Text, Number, Punctuation)),
|
|
|
|
(r'(-)([0-9]+)', bygroups(Punctuation, Number)),
|
|
|
|
(r'(\s*)(->|<=|>=|\*)', bygroups(Text, Operator)),
|
|
|
|
(r'(\s*)([\w()-=\'<>]+)', bygroups(Text, Comment)),
|
2013-06-12 01:29:36 +00:00
|
|
|
],
|
|
|
|
'boundary': [
|
2013-06-12 03:21:09 +00:00
|
|
|
(r'-{3,}\+$', Text, '#pop'),
|
|
|
|
(r'(-*)(//)(-+\+)?$', bygroups(Text, Generic.Strong, Text), '#pop'),
|
|
|
|
(r'-{3,}\+-', Text),
|
|
|
|
(r'-{3,}\+\s', Text, '#pop', 'content'),
|
|
|
|
(r'(-*)(//)(-+\+-)', bygroups(Text, Generic.Strong, Text)),
|
2013-06-12 01:29:36 +00:00
|
|
|
],
|
|
|
|
'content': [
|
2013-12-12 04:46:14 +00:00
|
|
|
(r'(\s*)(\+-)', bygroups(Text, Text), '#pop', 'boundary'),
|
2013-06-12 01:29:36 +00:00
|
|
|
(r'(\s*)([\+|])$', bygroups(Text, Text), '#pop'),
|
2014-02-03 20:13:39 +00:00
|
|
|
(r'(\s*)(\.)(\s*)(\.)(\s*)(\.)(\s)', bygroups(Text, Generic.Strong, Text, Generic.Strong, Text, Generic.Strong, Text)),
|
2013-06-12 02:00:14 +00:00
|
|
|
(r'(\s*)(\.\.\.)$', bygroups(Text, Generic.Strong), '#pop'),
|
2013-06-12 01:29:36 +00:00
|
|
|
(r'(\s*)(~)$', bygroups(Text, Generic.Strong), '#pop'),
|
2014-02-03 20:13:39 +00:00
|
|
|
(r'(\s*)([\w=;]+)$', bygroups(Text, Name.Tag), '#pop'),
|
|
|
|
(r'(\s*)([\w=;]+)', bygroups(Text, Name.Tag)),
|
2013-06-12 01:29:36 +00:00
|
|
|
(r'(\s*)(\|)', bygroups(Text, Text)),
|
2013-06-12 02:00:14 +00:00
|
|
|
(r'(\s*)(\()', bygroups(Text, Punctuation), 'expression'),
|
2014-02-18 03:08:38 +00:00
|
|
|
(r'(\s*)([+-])', bygroups(Text, Operator)),
|
2013-06-12 02:00:14 +00:00
|
|
|
],
|
|
|
|
'expression': [
|
|
|
|
(r'(\s*)(\))', bygroups(Text, Punctuation), '#pop'),
|
2013-06-12 02:12:44 +00:00
|
|
|
(r'(\s*)([+-])', bygroups(Text, Operator)),
|
|
|
|
(r'(\s*)(\$\w+)', bygroups(Text, Name.Tag)),
|
2013-06-12 02:00:14 +00:00
|
|
|
(r'(\s*)(\w+)', bygroups(Text, Name)),
|
2013-06-12 01:29:36 +00:00
|
|
|
],
|
|
|
|
}
|