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