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)),
|
2015-06-27 14:08:29 +00:00
|
|
|
(r'(\s*)`((?:[A-Z][a-z0-9]+)(?:[A-Z][a-z0-9]*)*)(\.)(.*)`', bygroups(Text, Name.Class, Operator, Name.Tag)),
|
2015-06-27 13:08:33 +00:00
|
|
|
(r'(\s*)`((?:[A-Z][a-z0-9]+)(?:[A-Z][a-z0-9]*)*)`', 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)),
|
2015-06-27 14:23:50 +00:00
|
|
|
(r'(\s*)(0x[0-9a-f]+)', bygroups(Text, Number.Hex)),
|
2015-06-29 12:41:40 +00:00
|
|
|
(r'(\s*)([0-9]+\.[0-9]+\.\w+)', bygroups(Text, Comment.Special)), # Versions
|
2013-06-12 02:27:14 +00:00
|
|
|
(r'(\s*)([0-9]+)(\+)?', bygroups(Text, Number, Punctuation)),
|
|
|
|
(r'(-)([0-9]+)', bygroups(Punctuation, Number)),
|
2015-06-27 14:23:50 +00:00
|
|
|
(r'(\s*)(->|<=|>=|\*|\^)', bygroups(Text, Operator)),
|
2017-04-07 10:17:31 +00:00
|
|
|
(r'(\s*)([\w=]*)(\{[\w]+\})', bygroups(Text, Text, Name.Tag)),
|
2015-06-27 14:23:50 +00:00
|
|
|
(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
|
|
|
],
|
|
|
|
}
|