UNPKG

proc_macro

Version:
56 lines 2.09 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var token_1 = __importDefault(require("./token")); /** * A non-literal token used to identify object (such as variables, conditions, etc). */ var Ident = /** @class */ (function (_super) { __extends(Ident, _super); function Ident(value) { var _this = _super.call(this) || this; _this.value = value; return _this; } Ident.prototype.eq = function (other) { if (other instanceof Ident) { return other.value === this.value; } return false; }; Ident.tokenize = function (tokenString) { var pointer = 0; var tokens = tokenString[0]; while (pointer < tokenString.length && /^[a-zA-Z_][a-zA-Z0-9_]*?$/.test(tokens)) { tokens += tokenString[++pointer]; } if (pointer === 0) { throw Error("Next token is not a ident."); } return [new Ident(tokenString.substring(0, pointer)), tokenString.substring(pointer)]; }; Ident.prototype.toParenthesisString = function () { return "(Ident " + this.value + ")"; }; Ident.prototype.toJavaScript = function () { return this.value + " "; }; return Ident; }(token_1.default)); exports.default = Ident; //# sourceMappingURL=ident.js.map