-
Notifications
You must be signed in to change notification settings - Fork 0
/
syntax.ts
51 lines (48 loc) · 1.34 KB
/
syntax.ts
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
// import { SyntaxDefinition } from 'code-syntax'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { join } from './util'
const ids = /[a-zA-Z_$][a-zA-Z0-9_$]*/
const num = /inf|nan|\d*\.?\d*e[+-]?\d+|(\d*\.((e[+-]?)?[\d]+)*\d+|\.\d+|\d+)([skKmbf]|ms)?/
const ops =
/%%|::|\?=|\+\+|--|\+=|-=|\*=|\/=|%=|<<=|>>=|&=|\^=|\|=|&&|!&|\|\||!=|==|>=|<=|>>|<<|\.\.|[[\](){}\\"'`,\-~+*/%=<>?!:;.|&^@]{1}/
export const syntax = {
// declare: [
// join(
// '',
// modify(
// '+', //
// join(
// '|', //
// ids,
// num,
// ops,
// /[[\](),.=\s+]/
// )
// ),
// /\)\s+=/
// ),
// {
// // arguments: [
// // /(?<=\().*?(?=\))/,
// // {
// // declare: num,
// // string: /[[\]]/,
// // arguments: /\w+/,
// // operator: ops,
// // },
// // ],
// arrow: /=$/,
// declare: ids,
// operator: ops,
// punctuation: /[[\]()]/,
// },
// ],
comment: join('|', /(\\\*)[^]*?(\*\\)/, /(\\\*)[^]*/, /(\s?(\\)(?!\*)[\S\s]*?(?=[\n\r]))/),
property: join('', ids, /(?=\()/),
declare: join('|', join('', /#/, ids), /#/),
regexp: /\b(t|pi2?|sr|br|mr)\b/,
normal: ids,
punctuation: /[[\](),]/,
number: num,
operator: ops,
} // as SyntaxDefinition