1 |
|
2 |
|
3 | "use strict";
|
4 |
|
5 | var _interopRequireDefault = require("babel-runtime/helpers/interop-require-default")["default"];
|
6 |
|
7 | var _tokenizerTypes = require("../tokenizer/types");
|
8 |
|
9 | var _index = require("./index");
|
10 |
|
11 | var _index2 = _interopRequireDefault(_index);
|
12 |
|
13 | var _utilWhitespace = require("../util/whitespace");
|
14 |
|
15 | var pp = _index2["default"].prototype;
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | pp.addExtra = function (node, key, val) {
|
22 | if (!node) return;
|
23 |
|
24 | var extra = node.extra = node.extra || {};
|
25 | extra[key] = val;
|
26 | };
|
27 |
|
28 |
|
29 |
|
30 | pp.isRelational = function (op) {
|
31 | return this.match(_tokenizerTypes.types.relational) && this.state.value === op;
|
32 | };
|
33 |
|
34 |
|
35 |
|
36 | pp.expectRelational = function (op) {
|
37 | if (this.isRelational(op)) {
|
38 | this.next();
|
39 | } else {
|
40 | this.unexpected();
|
41 | }
|
42 | };
|
43 |
|
44 |
|
45 |
|
46 | pp.isContextual = function (name) {
|
47 | return this.match(_tokenizerTypes.types.name) && this.state.value === name;
|
48 | };
|
49 |
|
50 |
|
51 |
|
52 | pp.eatContextual = function (name) {
|
53 | return this.state.value === name && this.eat(_tokenizerTypes.types.name);
|
54 | };
|
55 |
|
56 |
|
57 |
|
58 | pp.expectContextual = function (name) {
|
59 | if (!this.eatContextual(name)) this.unexpected();
|
60 | };
|
61 |
|
62 |
|
63 |
|
64 | pp.canInsertSemicolon = function () {
|
65 | return this.match(_tokenizerTypes.types.eof) || this.match(_tokenizerTypes.types.braceR) || _utilWhitespace.lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start));
|
66 | };
|
67 |
|
68 |
|
69 |
|
70 | pp.isLineTerminator = function () {
|
71 | return this.eat(_tokenizerTypes.types.semi) || this.canInsertSemicolon();
|
72 | };
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | pp.semicolon = function () {
|
78 | if (!this.eat(_tokenizerTypes.types.semi) && !this.canInsertSemicolon()) this.unexpected();
|
79 | };
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | pp.expect = function (type) {
|
85 | return this.eat(type) || this.unexpected();
|
86 | };
|
87 |
|
88 |
|
89 |
|
90 | pp.unexpected = function (pos) {
|
91 | this.raise(pos != null ? pos : this.state.start, "Unexpected token");
|
92 | }; |
\ | No newline at end of file |