-
Notifications
You must be signed in to change notification settings - Fork 0
/
cml-lexer.py
68 lines (66 loc) · 5.34 KB
/
cml-lexer.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from pygments.lexer import RegexLexer, words, include, bygroups
from pygments.token import *
import re
class CMLLexer(RegexLexer):
name = 'CML'
aliases = ['cml']
filenames = '*.cml'
flags = re.MULTILINE | re.DOTALL
tokens = {
'comments': [
(r'/\*.*?\*/', Comment),
(r'//.*?\n', Comment),
],
'strings': [
(r'".*?"', String)
],
'root': [
include('comments'),
include('strings'),
(r'(BoundedContext)(\s*)([a-zA-z]*)(\s*)(implements)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text, Text, Keyword, Text, Text)),
(r'(BoundedContext)(\s*)([a-zA-z]*)(\s*)(realizes)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text, Text, Keyword, Text, Text)),
(r'(BoundedContext)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text)),
(r'(Aggregate)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text)),
(r'(Entity)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text)),
(r'(ValueObject)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text)),
(r'(DomainEvent)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text)),
(r'(Subdomain)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text)),
(r'(contains)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text)),
(r'(responsibilities)(\s*)(=)(\s*)([a-zA-z]*)(\s*)(,)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text, Text, Text, Text, Text, Text, Text)),
(r'(responsibilities)(\s*)(=)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text, Text, Text)),
(r'(@[a-zA-Z_]*)(\s*)', bygroups(Text, Text)),
(r'([a-zA-z]*)(\s*)(<->)(\s*)([a-zA-z]*)(\s*)(:)(\s*)([a-zA-z-]*)', bygroups(Text, Text, Text, Text, Text, Text, Text, Text, Keyword)),
(r'([a-zA-z]*)(\s*)(->)(\s*)([a-zA-z]*)(\s*)(:)(\s*)([a-zA-z-]*)', bygroups(Text, Text, Text, Text, Text, Text, Text, Text, Keyword)),
(r'([a-zA-z]*)(\s*)(<-)(\s*)([a-zA-z]*)(\s*)(:)(\s*)([a-zA-z-]*)', bygroups(Text, Text, Text, Text, Text, Text, Text, Text, Keyword)),
(r'(upstream)(\s*)(implements)(\s*)([a-zA-Z_]*)(\s*)(,)(\s*)([a-zA-Z_]*)', bygroups(Keyword, Text, Keyword, Text, Keyword, Text, Text, Text, Keyword)),
(r'(upstream)(\s*)(implements)(\s*)([a-zA-Z_]*)(\s*)', bygroups(Keyword, Text, Keyword, Text, Keyword, Text)),
(r'(downstream)(\s*)(implements)(\s*)([a-zA-Z_]*)(\s*)(,)(\s*)([a-zA-Z_]*)', bygroups(Keyword, Text, Keyword, Text, Keyword, Text, Text, Text, Keyword)),
(r'(downstream)(\s*)(implements)(\s*)([a-zA-Z_]*)(\s*)', bygroups(Keyword, Text, Keyword, Text, Keyword, Text)),
(r'(supplier)(\s*)(implements)(\s*)([a-zA-Z_]*)(\s*)(,)(\s*)([a-zA-Z_]*)', bygroups(Keyword, Text, Keyword, Text, Keyword, Text, Text, Text, Keyword)),
(r'(supplier)(\s*)(implements)(\s*)([a-zA-Z_]*)(\s*)', bygroups(Keyword, Text, Keyword, Text, Keyword, Text)),
(r'(customer)(\s*)(implements)(\s*)([a-zA-Z_]*)(\s*)(,)(\s*)([a-zA-Z_]*)', bygroups(Keyword, Text, Keyword, Text, Keyword, Text, Text, Text, Keyword)),
(r'(customer)(\s*)(implements)(\s*)([a-zA-Z_]*)(\s*)', bygroups(Keyword, Text, Keyword, Text, Keyword, Text)),
(r'(String)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text)),
(r'(Account)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text)),
(r'(Customer)(\s*)([a-zA-z]*)', bygroups(Keyword, Text, Text)),
(r'(ANTICORRUPTION_LAYER|APPLICATION|AS_IS|AccessObject|Aggregate|Application|ApplicationPart|Bag|BasicType|'
r'BigDecimal|BigInteger|Blob|Boolean|BoundedContext|CHAR|CONCRETE|CONFORMIST|CORE_DOMAIN|Clob|Collection|'
r'CommandEvent|Consumer|ContextMap|Customer-Supplier|DELETE|DataTransferObject|Date|DateTime|DomainEvent|'
r'Double|Entity|FEATURE|Float|GENERIC_SUBDOMAIN|GET|INTEGER|Integer|JOINED|Key|List|Long|META|Module|None|'
r'OPEN_HOST_SERVICE|ORGANIZATIONAL|Object\[\]|POST|PUBLISHED_LANGUAGE|PUT|PagedResult|PagingParameter|Partnership|'
r'Repository|Resource|SINGLE_TABLE|STRING|SUPPORTING_DOMAIN|SYSTEM|SYSTEM_LANDSCAPE|Service|Set|Shared-Kernel|'
r'String|Subdomain|TEAM|TO_BE|Timestamp|Trait|Upstream-Downstream|ValueObject|abstract|aggregateRoot|assertFalse|'
r'assertTrue|auditable|basePackage|belongsTo|boolean|build|cache|cascade|changeable|condition|construct|contains|'
r'creditCardNumber|customer|databaseColumn|databaseJoinColumn|databaseJoinTable|databaseTable|databaseType|decimalMax|'
r'decimalMin|digits|discriminatorColumn|discriminatorLength|discriminatorType|discriminatorValue|domainVisionStatement|'
r'double|downstream|email|enum|eventBus|extends|external|fetch|float|future|gap|groupBy|hint|immutable|'
r'implementationTechnology|implements|import|index|inheritanceType|inject|int|inverse|key|knowledgeLevel|'
r'length|long|map|max|min|nogap|notBlank|notEmpty|nullable|optimisticLocking|orderBy|orderColumn|orderby|'
r'ordinal|package|past|path|pattern|persistent|private|protected|public|publish|query|queueName|range|realizes|'
r'required|responsibilities|return|scaffold|scriptAssert|select|size|state|subscribe|supplier|throws|to|topicName|'
r'transient|type|upstream|url|valid|validate|webservice|'
r'with)\b', Keyword),
('\s+', Text),
('\{|\=|\}|\-|:', Text),
]
}