forked from juliangruber/c-tokenizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rules.js
21 lines (21 loc) · 972 Bytes
/
rules.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module.exports = [
{ regex: /^\/\*([^*]|\*(?!\/))*\*\/$/, type: 'area comment' },
{ regex: /^\/\*([^*]|\*(?!\/))*\*?$/, type: 'area comment continue' },
{ regex: /^\/\/[^\n]*$/, type: 'line comment' },
{ regex: /^"([^"\n]|\\")*"?$/, type: 'quote' },
{ regex: /^'(\\?[^'\n]|\\')'?$/, type: 'char' },
{ regex: /^'[^']*$/, type: 'char continue' },
{ regex: /^#(\S*)$/, type: 'directive' },
{ regex: /^\($/, type: 'open paren' },
{ regex: /^\)$/, type: 'close paren' },
{ regex: /^\[$/, type: 'open square' },
{ regex: /^\]$/, type: 'close square' },
{ regex: /^{$/, type: 'open curly' },
{ regex: /^}$/, type: 'close curly' },
{ regex: /^([-<>~!%^&*\/+=?|.,:;]|->|<<|>>|\*\*|\|\||&&|--|\+\+|[-+*|&%\/=]=)$/,
type: 'operator' },
{ regex: /^([_A-Za-z]\w*)$/, type: 'identifier' },
{ regex: /^[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/, type: 'number' },
{ regex: /^(\s+)$/, type: 'whitespace' },
{ regex: /^\\\n?$/, type: 'line continue' }
]