Lines Matching full:this

4 // you may not use this file except in compliance with the License.
22 this.input_ = input;
23 this.len_ = input.length;
24 this.cur_pos_ = 0;
25 this.cur_line_ = 1;
27 this.num_regex_ = /^[0-9]+$/;
28 this.alpha_regex_ = /^[a-zA-Z_]+$/;
29 this.op_regex_ = /^Op[A-Z][^\s]*$/;
30 this.hex_regex_ = /^[0-9a-fA-F]$/;
38 this.skipWhitespace();
39 this.skipComments();
41 if (this.cur_pos_ >= this.len_)
42 return new Token(TokenType.kEOF, this.cur_line_);
44 let n = this.tryHexInteger();
48 n = this.tryFloat();
52 n = this.tryInteger();
56 n = this.tryString();
60 n = this.tryOp();
64 n = this.tryPunctuation();
68 n = this.tryResultId();
72 n = this.tryIdent();
76 return new Token(TokenType.kError, this.cur_line_, "Failed to match token");
80 if (this.len_ <= this.cur_pos_ + (str.length - 1))
84 if (this.input_[this.cur_pos_ + i] !== str[i])
92 return ch.match(this.num_regex_);
96 return ch.match(this.alpha_regex_);
100 return this.isNum(ch) || this.isAlpha(ch);
104 return char.match(this.hex_regex_);
108 return this.is(" ") || this.is("\t") || this.is("\r") || this.is("\n");
113 let cur_pos = this.cur_pos_;
114 while (this.cur_pos_ < this.len_ &&
115 this.isCurWhitespace()) {
116 if (this.is("\n"))
117 this.cur_line_ += 1;
119 this.cur_pos_ += 1;
122 this.skipComments();
125 if (cur_pos === this.cur_pos_)
131 if (!this.is(";"))
134 while (this.cur_pos_ < this.len_ && !this.is("\n"))
135 this.cur_pos_ += 1;
144 let start = this.cur_pos_;
147 if (this.cur_pos_ >= this.len_)
149 if (this.input_[end] === "-")
152 while (end < this.len_ && this.isNum(this.input_[end]))
156 if (end >= this.len_ || this.input_[end] !== ".")
160 while (end < this.len_ && this.isNum(this.input_[end]))
163 let substr = this.input_.substr(start, end - start);
167 this.cur_pos_ = end;
169 return new Token(TokenType.kFloatLiteral, this.cur_line_, parseFloat(substr));
178 let start = this.cur_pos_;
181 if (this.cur_pos_ >= this.len_)
183 if (end + 2 >= this.len_ || this.input_[end] !== "0" ||
184 this.input_[end + 1] !== "x") {
190 while (end < this.len_ && this.isHex(this.input_[end]))
193 this.cur_pos_ = end;
195 let val = parseInt(this.input_.substr(start, end - start), 16);
196 return new Token(TokenType.kIntegerLiteral, this.cur_line_, val);
205 let start = this.cur_pos_;
208 if (this.cur_pos_ >= this.len_)
210 if (this.input_[end] === "-")
213 if (end >= this.len_ || !this.isNum(this.input_[end]))
216 while (end < this.len_ && this.isNum(this.input_[end]))
219 this.cur_pos_ = end;
221 let val = parseInt(this.input_.substr(start, end - start), 10);
222 return new Token(TokenType.kIntegerLiteral, this.cur_line_, val);
231 let start = this.cur_pos_;
232 if (start >= this.len_)
234 if (!this.is("%"))
238 this.cur_pos_ += 1;
239 while (this.cur_pos_ < this.len_ &&
240 (this.isAlphaNum(this.input_[this.cur_pos_]) || this.is("_"))) {
241 this.cur_pos_ += 1;
244 let ident = this.input_.substr(start, this.cur_pos_ - start);
246 if (ident.match(this.num_regex_))
249 return new Token(TokenType.kResultId, this.cur_line_, {
261 let start = this.cur_pos_;
262 if (start >= this.len_)
265 while (this.cur_pos_ < this.len_ &&
266 (this.isAlphaNum(this.input_[this.cur_pos_]) || this.is("_"))) {
267 this.cur_pos_ += 1;
270 let ident = this.input_.substr(start, this.cur_pos_ - start);
271 return new Token(TokenType.kIdentifier, this.cur_line_, ident);
280 let start = this.cur_pos_;
281 if (this.cur_pos_ >= this.len_ || (this.cur_pos_ + 1 >= this.len_))
284 if (this.input_[this.cur_pos_] !== "O" ||
285 this.input_[this.cur_pos_ + 1] !== "p") {
289 while (this.cur_pos_ < this.len_ &&
290 !this.isCurWhitespace()) {
291 this.cur_pos_ += 1;
294 return new Token(TokenType.kOp, this.cur_line_, {
295 name: this.input_.substr(start, this.cur_pos_ - start)
306 if (this.is("="))
308 else if (this.is("|"))
314 this.cur_pos_ += type.length;
315 return new Token(type, this.cur_line_, type);
324 let start = this.cur_pos_;
327 if (this.cur_pos_ >= this.len_ || (this.cur_pos_ + 1 >= this.len_))
329 if (!this.is("\""))
332 this.cur_pos_ += 1;
334 while (this.cur_pos_ <= this.len_) {
335 if (this.is("\""))
338 if (this.is("\\")) {
339 this.cur_pos_ += 1;
340 if (this.cur_pos_ >= this.len_)
343 if (this.is("\\")) {
345 } else if (this.is("\"")) {
348 str += this.input_[this.cur_pos_];
351 str += this.input_[this.cur_pos_];
353 this.cur_pos_ += 1;
356 if (this.cur_pos_ >= this.len_)
359 this.cur_pos_ += 1;
361 return new Token(TokenType.kStringLiteral, this.cur_line_, str);