@making-sense/antlr-editor
Version:
ANTLR Typescript editor
53 lines • 1.88 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleToken = void 0;
const multiplyMode_1 = require("./multiplyMode");
const tokenType_1 = require("./tokenType");
class RuleToken {
constructor(type, nested, name, value) {
this.nested = 0;
this.multiplied = multiplyMode_1.MultiplyMode.None;
this.greedy = true;
this.type = type;
if (nested)
this.nested = nested;
if (name)
this.name = name;
if (value)
this.value = value;
}
multiply(type) {
let multiplied;
switch (type) {
case tokenType_1.TokenType.Question:
multiplied = multiplyMode_1.MultiplyMode.Optional;
break;
case tokenType_1.TokenType.Plus:
multiplied = multiplyMode_1.MultiplyMode.Onemore;
break;
case tokenType_1.TokenType.Star:
multiplied = multiplyMode_1.MultiplyMode.Zeromore;
break;
default:
return;
}
if (this.multiplied === multiplied)
return;
this.multiplied = this.multiplied === multiplyMode_1.MultiplyMode.None ? multiplied : multiplyMode_1.MultiplyMode.Zeromore;
}
label(identifier) {
this.identifier = identifier;
}
isAssign() {
return this.type === tokenType_1.TokenType.Assign || this.type === tokenType_1.TokenType.PlusAssign;
}
isAtom() {
return (this.type === tokenType_1.TokenType.Keyword ||
this.type === tokenType_1.TokenType.Operator ||
this.type === tokenType_1.TokenType.Operand ||
this.type === tokenType_1.TokenType.Rule ||
this.type === tokenType_1.TokenType.Unknown);
}
}
exports.RuleToken = RuleToken;
//# sourceMappingURL=ruleToken.js.map