1 | define(["../_base"], function(dh){ |
---|
2 | |
---|
3 | var DELPHI_KEYWORDS = { |
---|
4 | 'and': 1, 'safecall': 1, 'cdecl': 1, 'then': 1, 'string': 1, |
---|
5 | 'exports': 1, 'library': 1, 'not': 1, 'pascal': 1, 'set': 1, |
---|
6 | 'virtual': 1, 'file': 1, 'in': 1, 'array': 1, 'label': 1, 'packed': 1, |
---|
7 | 'end.': 1, 'index': 1, 'while': 1, 'const': 1, 'raise': 1, 'for': 1, |
---|
8 | 'to': 1, 'implementation': 1, 'with': 1, 'except': 1, 'overload': 1, |
---|
9 | 'destructor': 1, 'downto': 1, 'finally': 1, 'program': 1, 'exit': 1, |
---|
10 | 'unit': 1, 'inherited': 1, 'override': 1, 'if': 1, 'type': 1, |
---|
11 | 'until': 1, 'function': 1, 'do': 1, 'begin': 1, 'repeat': 1, 'goto': 1, |
---|
12 | 'nil': 1, 'far': 1, 'initialization': 1, 'object': 1, 'else': 1, |
---|
13 | 'var': 1, 'uses': 1, 'external': 1, 'resourcestring': 1, |
---|
14 | 'interface': 1, 'end': 1, 'finalization': 1, 'class': 1, 'asm': 1, |
---|
15 | 'mod': 1, 'case': 1, 'on': 1, 'shr': 1, 'shl': 1, 'of': 1, |
---|
16 | 'register': 1, 'xorwrite': 1, 'threadvar': 1, 'try': 1, 'record': 1, |
---|
17 | 'near': 1, 'stored': 1, 'constructor': 1, 'stdcall': 1, 'inline': 1, |
---|
18 | 'div': 1, 'out': 1, 'or': 1, 'procedure': 1 |
---|
19 | }; |
---|
20 | var DELPHI_CLASS_KEYWORDS = { |
---|
21 | 'safecall': 1, 'stdcall': 1, 'pascal': 1, 'stored': 1, 'const': 1, |
---|
22 | 'implementation': 1, 'finalization': 1, 'except': 1, 'to': 1, |
---|
23 | 'finally': 1, 'program': 1, 'inherited': 1, 'override': 1, 'then': 1, |
---|
24 | 'exports': 1, 'string': 1, 'read': 1, 'not': 1, 'mod': 1, 'shr': 1, |
---|
25 | 'try': 1, 'div': 1, 'shl': 1, 'set': 1, 'library': 1, 'message': 1, |
---|
26 | 'packed': 1, 'index': 1, 'for': 1, 'near': 1, 'overload': 1, |
---|
27 | 'label': 1, 'downto': 1, 'exit': 1, 'public': 1, 'goto': 1, |
---|
28 | 'interface': 1, 'asm': 1, 'on': 1, 'of': 1, 'constructor': 1, 'or': 1, |
---|
29 | 'private': 1, 'array': 1, 'unit': 1, 'raise': 1, 'destructor': 1, |
---|
30 | 'var': 1, 'type': 1, 'until': 1, 'function': 1, 'else': 1, |
---|
31 | 'external': 1, 'with': 1, 'case': 1, 'default': 1, 'record': 1, |
---|
32 | 'while': 1, 'protected': 1, 'property': 1, 'procedure': 1, |
---|
33 | 'published': 1, 'and': 1, 'cdecl': 1, 'do': 1, 'threadvar': 1, |
---|
34 | 'file': 1, 'in': 1, 'if': 1, 'end': 1, 'virtual': 1, 'write': 1, |
---|
35 | 'far': 1, 'out': 1, 'begin': 1, 'repeat': 1, 'nil': 1, |
---|
36 | 'initialization': 1, 'object': 1, 'uses': 1, 'resourcestring': 1, |
---|
37 | 'class': 1, 'register': 1, 'xorwrite': 1, 'inline': 1 |
---|
38 | }; |
---|
39 | |
---|
40 | var dhc = dh.constants; |
---|
41 | dh.languages.delphi = { |
---|
42 | // summary: |
---|
43 | // Delphi highlight definitions |
---|
44 | defaultMode: { |
---|
45 | lexems: [dhc.IDENT_RE], |
---|
46 | illegal: '("|\\$[G-Zg-z]|\\/\\*|</)', |
---|
47 | contains: ['comment', 'string', 'number', 'function', 'class'], |
---|
48 | keywords: DELPHI_KEYWORDS |
---|
49 | }, |
---|
50 | case_insensitive: true, |
---|
51 | modes: [ |
---|
52 | { |
---|
53 | className: 'comment', |
---|
54 | begin: '{', end: '}' |
---|
55 | }, |
---|
56 | { |
---|
57 | className: 'comment', |
---|
58 | begin: '\\(\\*', end: '\\*\\)', |
---|
59 | relevance: 10 |
---|
60 | }, |
---|
61 | dhc.C_LINE_COMMENT_MODE, |
---|
62 | { |
---|
63 | className: 'number', |
---|
64 | begin: dhc.NUMBER_RE, end: '^', |
---|
65 | relevance: 0 |
---|
66 | }, |
---|
67 | { |
---|
68 | className: 'string', |
---|
69 | begin: '\'', end: '\'', |
---|
70 | contains: ['quote'], |
---|
71 | relevance: 0 |
---|
72 | }, |
---|
73 | { |
---|
74 | className: 'string', |
---|
75 | begin: '(#\\d+)+', end: '^' |
---|
76 | }, |
---|
77 | { |
---|
78 | className: 'quote', |
---|
79 | begin: '\'\'', end: '^' |
---|
80 | }, |
---|
81 | { |
---|
82 | className: 'function', |
---|
83 | begin: 'function', end: '[:;]', |
---|
84 | lexems: [dhc.IDENT_RE], |
---|
85 | keywords: {'function': 1}, |
---|
86 | contains: ['title', 'params', 'comment'], |
---|
87 | relevance: 0 |
---|
88 | }, |
---|
89 | { |
---|
90 | className: 'function', |
---|
91 | begin: '(procedure|constructor|destructor)', end: ';', |
---|
92 | lexems: [dhc.IDENT_RE], |
---|
93 | keywords: {'constructor': 1, 'destructor': 1, 'procedure': 1}, |
---|
94 | contains: ['title', 'params', 'comment'], |
---|
95 | relevance: 10 |
---|
96 | }, |
---|
97 | { |
---|
98 | className: 'title', |
---|
99 | begin: dhc.IDENT_RE, end: '^' |
---|
100 | }, |
---|
101 | { |
---|
102 | className: 'params', |
---|
103 | begin: '\\(', end: '\\)', |
---|
104 | lexems: [dhc.IDENT_RE], |
---|
105 | keywords: DELPHI_KEYWORDS, |
---|
106 | contains: ['string'] |
---|
107 | }, |
---|
108 | { |
---|
109 | className: 'class', |
---|
110 | begin: '=\\s*class', end: 'end;', |
---|
111 | lexems: [dhc.IDENT_RE], |
---|
112 | keywords: DELPHI_CLASS_KEYWORDS, |
---|
113 | contains: ['string', 'comment', 'function'] |
---|
114 | } |
---|
115 | ] |
---|
116 | }; |
---|
117 | |
---|
118 | return dh.languages.delphi |
---|
119 | }); |
---|