1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | var TESTS = [
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | 'EMAIL', (/^([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.(?:[a-z]{2}|co\.uk|com|edu|net|org))\b/)
|
26 |
|
27 | , 'AT_STAR_OPEN', (/^(@\*)/)
|
28 | , 'AT_STAR_CLOSE', (/^(\*@)/)
|
29 |
|
30 |
|
31 | , 'AT_COLON', (/^(@\:)/)
|
32 | , 'AT', (/^(@)/)
|
33 |
|
34 |
|
35 | , 'PAREN_OPEN', (/^(\()/)
|
36 | , 'PAREN_CLOSE', (/^(\))/)
|
37 |
|
38 |
|
39 | , 'HARD_PAREN_OPEN', (/^(\[)/)
|
40 | , 'HARD_PAREN_CLOSE', (/^(\])/)
|
41 |
|
42 |
|
43 | , 'BRACE_OPEN', (/^(\{)/)
|
44 | , 'BRACE_CLOSE', (/^(\})/)
|
45 |
|
46 |
|
47 | , 'HTML_TAG_VOID_CLOSE', (/^(\/>)/)
|
48 | , 'HTML_TAG_CLOSE', (/^(<\/)/)
|
49 | , 'HTML_COMMENT_OPEN', (/^(<!--+)/)
|
50 | , 'HTML_COMMENT_CLOSE', (/^(--+>)/)
|
51 | , 'LT_SIGN', (/^(<)/)
|
52 | , 'GT_SIGN', (/^(>)/)
|
53 |
|
54 | , 'ASSIGNMENT_OPERATOR', (/^(\|=|\^=|&=|>>>=|>>=|<<=|-=|\+=|%=|\/=|\*=)\b/)
|
55 | , 'EQUALITY_OPERATOR', (/^(===|==|!==|!=)\b/)
|
56 | , 'BITWISE_SHIFT_OPERATOR', (/^(<<|>>>|>>)/)
|
57 | , 'UNARY_OPERATOR', (/^(delete\b|typeof\b|void|\+\+|--|\+|-|~|!)/)
|
58 | , 'RELATIONAL_OPERATOR', (/^(<=|>=|instanceof|in)\b/)
|
59 | , 'BINARY_LOGICAL_OPERATOR', (/^(&&|\|\|)\b/)
|
60 | , 'BINARY_BITWISE_OPERATOR', (/^(&|\^|\|)\b/)
|
61 | , 'NEW_OPERATOR', (/^(new)\b/)
|
62 | , 'COMMA_OPERATOR', (/^(,)/)
|
63 |
|
64 | , 'EQUAL_SIGN', (/^(=)/)
|
65 | , 'COLON', (/^(:)/)
|
66 | , 'PERIOD', (/^(\.)/)
|
67 | , 'NEWLINE', function(){
|
68 | var token = this.scan(/^(\n)/, exports.NEWLINE);
|
69 | if(token){
|
70 | this.lineno++;
|
71 | this.charno = 0;
|
72 | }
|
73 | return token;
|
74 | }
|
75 | , 'WHITESPACE', (/^([^\S\n]+)/)
|
76 | , 'FUNCTION', (/^(function)(?![\d\w])/)
|
77 | , 'BLOCK_KEYWORD', (/^(catch|do|else if|else|finally|for|function|goto|if|switch|try|while|with)(?![\d\w])/)
|
78 | , 'KEYWORD', (/^(break|case|continue|instanceof|return|var)(?![\d\w])/)
|
79 | , 'IDENTIFIER', (/^([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)/)
|
80 |
|
81 | , 'DOUBLE_FORWARD_SLASH', (/^(\/\/)/)
|
82 |
|
83 | , 'FORWARD_SLASH', (/^(\/)/)
|
84 |
|
85 | , 'BACKSLASH', (/^(\\)/)
|
86 | , 'EXCLAMATION_POINT', (/^(!)/)
|
87 | , 'DOUBLE_QUOTE', (/^(\")/)
|
88 | , 'SINGLE_QUOTE', (/^(\')/)
|
89 |
|
90 | , 'NUMERAL', (/^([0-9])/)
|
91 | , 'CONTENT', (/^([^\s])/)
|
92 |
|
93 | ];
|
94 |
|
95 | exports.tests = TESTS;
|
96 |
|
97 |
|
98 | for(var i = 0; i < TESTS.length; i += 2) {
|
99 | exports[TESTS[i]] = TESTS[i];
|
100 | } |
\ | No newline at end of file |