1fd4e5da5Sopenharmony_ci// Copyright 2019 Google LLC
2fd4e5da5Sopenharmony_ci//
3fd4e5da5Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4fd4e5da5Sopenharmony_ci// you may not use this file except in compliance with the License.
5fd4e5da5Sopenharmony_ci// You may obtain a copy of the License at
6fd4e5da5Sopenharmony_ci//
7fd4e5da5Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
8fd4e5da5Sopenharmony_ci//
9fd4e5da5Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10fd4e5da5Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
11fd4e5da5Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fd4e5da5Sopenharmony_ci// See the License for the specific language governing permissions and
13fd4e5da5Sopenharmony_ci// limitations under the License.
14fd4e5da5Sopenharmony_ci
15fd4e5da5Sopenharmony_ciconst TokenType = {
16fd4e5da5Sopenharmony_ci  kEOF: "end of file",
17fd4e5da5Sopenharmony_ci  kError: "error",
18fd4e5da5Sopenharmony_ci
19fd4e5da5Sopenharmony_ci  kIdentifier: "identifier",
20fd4e5da5Sopenharmony_ci
21fd4e5da5Sopenharmony_ci  kIntegerLiteral: "integer_literal",
22fd4e5da5Sopenharmony_ci  kFloatLiteral: "float_literal",
23fd4e5da5Sopenharmony_ci  kStringLiteral: "string_literal",
24fd4e5da5Sopenharmony_ci  kResultId: "result_id",
25fd4e5da5Sopenharmony_ci
26fd4e5da5Sopenharmony_ci  kOp: "Op",
27fd4e5da5Sopenharmony_ci  kEqual: "=",
28fd4e5da5Sopenharmony_ci  kPipe: "|",
29fd4e5da5Sopenharmony_ci};
30fd4e5da5Sopenharmony_ci
31fd4e5da5Sopenharmony_ciclass Token {
32fd4e5da5Sopenharmony_ci  /**
33fd4e5da5Sopenharmony_ci   * @param {TokenType} type The type of token
34fd4e5da5Sopenharmony_ci   * @param {Integer} line The line number this token was on
35fd4e5da5Sopenharmony_ci   * @param {Any} data Data attached to the token
36fd4e5da5Sopenharmony_ci   * @param {Integer} bits If the type is a float or integer the bit width
37fd4e5da5Sopenharmony_ci   */
38fd4e5da5Sopenharmony_ci  constructor(type, line, data) {
39fd4e5da5Sopenharmony_ci    this.type_ = type;
40fd4e5da5Sopenharmony_ci    this.line_ = line;
41fd4e5da5Sopenharmony_ci    this.data_ = data;
42fd4e5da5Sopenharmony_ci    this.bits_ = 0;
43fd4e5da5Sopenharmony_ci  }
44fd4e5da5Sopenharmony_ci
45fd4e5da5Sopenharmony_ci  get type() { return this.type_; }
46fd4e5da5Sopenharmony_ci  get line() { return this.line_; }
47fd4e5da5Sopenharmony_ci
48fd4e5da5Sopenharmony_ci  get data() { return this.data_; }
49fd4e5da5Sopenharmony_ci  set data(val) { this.data_ = val; }
50fd4e5da5Sopenharmony_ci
51fd4e5da5Sopenharmony_ci  get bits() { return this.bits_; }
52fd4e5da5Sopenharmony_ci  set bits(val) { this.bits_ = val; }
53fd4e5da5Sopenharmony_ci}
54fd4e5da5Sopenharmony_ci
55fd4e5da5Sopenharmony_ciexport {Token, TokenType};
56