|
1 | 1 | ---
|
2 | 2 | title: Parser
|
3 | 3 | group: Plugins
|
4 |
| -sort: 8 |
| 4 | +sort: 4 |
5 | 5 | ---
|
6 | 6 |
|
7 | 7 | The parser instance takes a String and callback and will return an expression when there's a match.
|
8 | 8 |
|
9 |
| -```javascript |
| 9 | +``` js |
10 | 10 | compiler.parser.plugin("var rewire", function (expr) {
|
11 | 11 | //if you original module has 'var rewire'
|
12 | 12 | //you now have a handle on the expresssion object
|
13 | 13 | return true;
|
14 | 14 | });
|
15 | 15 | ```
|
16 | 16 |
|
| 17 | + |
17 | 18 | ## `program(ast)` bailing
|
18 | 19 |
|
19 | 20 | General purpose plugin interface for the AST of a code fragment.
|
20 | 21 |
|
| 22 | + |
21 | 23 | ## `statement(statement: Statement)` bailing
|
22 | 24 |
|
23 | 25 | General purpose plugin interface for the statements of the code fragment.
|
24 | 26 |
|
| 27 | + |
25 | 28 | ## `call <identifier>(expr: Expression)` bailing
|
26 | 29 |
|
27 | 30 | `abc(1)` => `call abc`
|
28 | 31 |
|
29 | 32 | `a.b.c(1)` => `call a.b.c`
|
30 | 33 |
|
| 34 | + |
31 | 35 | ## `expression <identifier>(expr: Expression)` bailing
|
32 | 36 |
|
33 | 37 | `abc` => `expression abc`
|
34 | 38 |
|
35 | 39 | `a.b.c` => `expression a.b.c`
|
36 | 40 |
|
| 41 | + |
37 | 42 | ## `expression ?:(expr: Expression)` bailing
|
38 | 43 |
|
39 | 44 | `(abc ? 1 : 2)` => `expression ?!`
|
40 | 45 |
|
41 | 46 | Return a boolean value to omit parsing of the wrong path.
|
42 | 47 |
|
| 48 | + |
43 | 49 | ## `typeof <identifier>(expr: Expression)` bailing
|
44 | 50 |
|
45 | 51 | `typeof a.b.c` => `typeof a.b.c`
|
46 | 52 |
|
| 53 | + |
47 | 54 | ## `statement if(statement: Statement)` bailing
|
48 | 55 |
|
49 | 56 | `if(abc) {}` => `statement if`
|
50 | 57 |
|
51 | 58 | Return a boolean value to omit parsing of the wrong path.
|
52 | 59 |
|
| 60 | + |
53 | 61 | ## `label <labelname>(statement: Statement)` bailing
|
54 | 62 |
|
55 | 63 | `xyz: abc` => `label xyz`
|
56 | 64 |
|
| 65 | + |
57 | 66 | ## `var <name>(statement: Statement)` bailing
|
58 | 67 |
|
59 | 68 | `var abc, def` => `var abc` + `var def`
|
60 | 69 |
|
61 | 70 | Return `false` to not add the variable to the known definitions.
|
62 | 71 |
|
| 72 | + |
63 | 73 | ## `evaluate <expression type>(expr: Expression)` bailing
|
64 | 74 |
|
65 | 75 | Evaluate an expression.
|
66 | 76 |
|
| 77 | + |
67 | 78 | ## `evaluate typeof <identifier>(expr: Expression)` bailing
|
68 | 79 |
|
69 | 80 | Evaluate the type of an identifier.
|
70 | 81 |
|
| 82 | + |
71 | 83 | ## `evaluate Identifier <identifier>(expr: Expression)` bailing
|
72 | 84 |
|
73 | 85 | Evaluate a identifier that is a free var.
|
74 | 86 |
|
| 87 | + |
75 | 88 | ## `evaluate defined Identifier <identifier>(expr: Expression)` bailing
|
76 | 89 |
|
77 | 90 | Evaluate a identifier that is a defined var.
|
78 | 91 |
|
| 92 | + |
79 | 93 | ## `evaluate CallExpression .<property>(expr: Expression)` bailing
|
80 | 94 |
|
81 | 95 | Evaluate a call to a member function of a successfully evaluated expression.
|
0 commit comments