antlr-ng
Version:
Next generation ANTLR Tool
67 lines (66 loc) • 2.81 kB
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
import { Lexer } from "antlr4ng";
import { DictType } from "./misc/types.js";
import { AttributeDict } from "./tool/AttributeDict.js";
class Constants {
static {
__name(this, "Constants");
}
static GrammarExtension = ".g4";
static LegacyGrammarExtension = ".g";
static AllGrammarExtensions = [Constants.GrammarExtension, Constants.LegacyGrammarExtension];
static DefaultNodeName = "DEFAULT_MODE";
static PrecedenceOptionName = "p";
static TokenIndexOptionName = "tokenIndex";
static VocabFileExtension = ".tokens";
static GrammarFromStringName = "<string>";
static EorTokenType = 1;
static Down = 2;
static Up = 3;
/**
* Rule refs have a predefined set of attributes as well as the return values and args.
*
* These must be consistent with ActionTranslator.rulePropToModelMap, ...
*/
static predefinedRulePropertiesDict = new AttributeDict(DictType.PredefinedRule);
/**
* All {@link Token} scopes (token labels) share the same fixed scope of of predefined attributes. I keep this
* out of the {@link Token} interface to avoid a runtime type leakage.
*/
static predefinedTokenDict = new AttributeDict(DictType.Token);
/**
* Provides a map of names of predefined constants which are likely to appear as the argument for lexer commands.
* These names are required during code generation for creating {@link LexerAction} instances that are usable
* by a lexer interpreter.
*/
static COMMON_CONSTANTS = /* @__PURE__ */ new Map([
["HIDDEN", Lexer.HIDDEN],
["DEFAULT_TOKEN_CHANNEL", Lexer.DEFAULT_TOKEN_CHANNEL],
["DEFAULT_MODE", Lexer.DEFAULT_MODE],
["SKIP", Lexer.SKIP],
["MORE", Lexer.MORE],
["EOF", Lexer.EOF],
//["MAX_CHAR_VALUE", Lexer.MAX_CHAR_VALUE], // TODO: are these constants needed?
//["MIN_CHAR_VALUE", Lexer.MIN_CHAR_VALUE],
["MAX_CHAR_VALUE", 131071],
["MIN_CHAR_VALUE", 0]
]);
static {
Constants.predefinedRulePropertiesDict.add({ name: "parser" });
Constants.predefinedRulePropertiesDict.add({ name: "text" });
Constants.predefinedRulePropertiesDict.add({ name: "start" });
Constants.predefinedRulePropertiesDict.add({ name: "stop" });
Constants.predefinedRulePropertiesDict.add({ name: "ctx" });
Constants.predefinedTokenDict.add({ name: "text" });
Constants.predefinedTokenDict.add({ name: "type" });
Constants.predefinedTokenDict.add({ name: "line" });
Constants.predefinedTokenDict.add({ name: "index" });
Constants.predefinedTokenDict.add({ name: "pos" });
Constants.predefinedTokenDict.add({ name: "channel" });
Constants.predefinedTokenDict.add({ name: "int" });
}
}
export {
Constants
};