source: Dev/branches/rest-dojo-ui/client/dojox/highlight/languages/delphi.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 3.9 KB
Line 
1define(["dojox/main", "../_base"], function(dojox){
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 dh = dojox.highlight, dhc = dh.constants;
41        dh.languages.delphi = {
42                // summary: Delphi highlight definitions
43                defaultMode: {
44                        lexems: [dhc.IDENT_RE],
45                        illegal: '("|\\$[G-Zg-z]|\\/\\*|</)',
46                        contains: ['comment', 'string', 'number', 'function', 'class'],
47                        keywords: DELPHI_KEYWORDS
48                },
49                case_insensitive: true,
50                modes: [
51                        {
52                                className: 'comment',
53                                begin: '{', end: '}'
54                        },
55                        {
56                                className: 'comment',
57                                begin: '\\(\\*', end: '\\*\\)',
58                                relevance: 10
59                        },
60                        dhc.C_LINE_COMMENT_MODE,
61                        {
62                                className: 'number',
63                                begin: dhc.NUMBER_RE, end: '^',
64                                relevance: 0
65                        },
66                        {
67                                className: 'string',
68                                begin: '\'', end: '\'',
69                                contains: ['quote'],
70                                relevance: 0
71                        },
72                        {
73                                className: 'string',
74                                begin: '(#\\d+)+', end: '^'
75                        },
76                        {
77                                className: 'quote',
78                                begin: '\'\'', end: '^'
79                        },
80                        {
81                                className: 'function',
82                                begin: 'function', end: '[:;]',
83                                lexems: [dhc.IDENT_RE],
84                                keywords: {'function': 1},
85                                contains: ['title', 'params', 'comment'],
86                                relevance: 0
87                        },
88                        {
89                                className: 'function',
90                                begin: '(procedure|constructor|destructor)', end: ';',
91                                lexems: [dhc.IDENT_RE],
92                                keywords: {'constructor': 1, 'destructor': 1, 'procedure': 1},
93                                contains: ['title', 'params', 'comment'],
94                                relevance: 10
95                        },
96                        {
97                                className: 'title',
98                                begin: dhc.IDENT_RE, end: '^'
99                        },
100                        {
101                                className: 'params',
102                                begin: '\\(', end: '\\)',
103                                lexems: [dhc.IDENT_RE],
104                                keywords: DELPHI_KEYWORDS,
105                                contains: ['string']
106                        },
107                        {
108                                className: 'class',
109                                begin: '=\\s*class', end: 'end;',
110                                lexems: [dhc.IDENT_RE],
111                                keywords: DELPHI_CLASS_KEYWORDS,
112                                contains: ['string', 'comment', 'function']
113                        }
114                ]
115        };
116
117        return dh.languages.delphi
118});
Note: See TracBrowser for help on using the repository browser.