forked from phpcr/phpcr-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlexer_cnd.py
40 lines (37 loc) · 1.28 KB
/
lexer_cnd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from pygments.lexer import RegexLexer
from pygments.token import *
import re
class CndLexer(RegexLexer):
"""
For JCR Compact Namespace and Node Type Definition files.
"""
name = 'Cnd'
aliases = ['cnd']
filenames = ['*.cnd']
tokens = {
'root': [
(r'^<.*?>', Name.Namespace),
(r'^//.*$', Comment),
(r'/\*\*/', Comment.Multiline),
(r'/\*.*?\*/', Comment.Multiline),
(r'\[.*?\]', Name.Entity, 'nodetype'),
(r'\((string|binary|long|double|date|boolean|name|path|reference|weakreference|uri|decimal)\)', Name.Label),
(r'(\[|\(|\)|\])', Name.Tag),
(r'^\+', Keyword.Declaration),
(r'^\-', Keyword.Declaration),
(r'(mandatory|autocreated|protected|version|primary)', Keyword),
(r'(mixin|orderable)', Keyword),
(r'(mandatory|autocreated|protected|multiple|version|primary)', Keyword),
(r'(>|=|<|\*)', Operator),
(r'\'.*?\'', String.Single),
(r',', Punctuation),
(r'\s+', Text),
(r'[\w:]', Text),
],
'nodetype': [
(r'>', Name.Punctuation),
(r'[\w:]', Name.Class),
(r',', Punctuation),
(r' ', Text),
]
}