configuration/constants/syntax.constants.ts
configuration/constants/syntax.constants.ts is a file in Bane's Lab Site. 116 lines of code and 24 definitions.
import {
BNF_LANGUAGE,
JAVASCRIPT_LANGUAGE,
JSON_LANGUAGE,
MARKDOWN_LANGUAGE,
MERMAID_LANGUAGE,
PAG_LANGUAGE,
TYPESCRIPT_LANGUAGE,
YAML_LANGUAGE,
} from "#configuration/constants/code.constants";
import type { TokenKind } from "#types/syntax.types";
export const STRING_TOKEN_CLASS = "syntax-string";
export const SYNTAX_CLASSES: ReadonlyMap<TokenKind, string> = new Map<TokenKind, string>([
["comment", "syntax-comment"],
["constant", "syntax-constant"],
["heading", "syntax-heading"],
["keyword", "syntax-keyword"],
["number", "syntax-number"],
["string", STRING_TOKEN_CLASS],
["type", "syntax-type"],
]);
export const CODE_LINE_CLASS = "code-line";
export const CODE_LINE_ATTRIBUTE = "data-line";
export const CODE_LINE_MARKED_CLASS = "marked";
export const LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
export const DIGITS = "0123456789";
export const WORD_CHARS = `${LETTERS + DIGITS}-`;
export const QUOTES = "\"'`";
export const ESCAPE = "\\";
export const ANGLE_OPEN = "<";
export const ANGLE_CLOSE = ">";
export const CLOSING_MARK = "/";
const DOUBLE_SLASH = "//";
export const HASH = "#";
const DOUBLE_PERCENT = "%%";
const SCRIPT_KEYWORDS = [
"as",
"async",
"await",
"break",
"case",
"catch",
"class",
"const",
"continue",
"default",
"delete",
"do",
"else",
"enum",
"export",
"extends",
"false",
"finally",
"for",
"from",
"function",
"if",
"implements",
"import",
"in",
"instanceof",
"interface",
"let",
"new",
"null",
"of",
"readonly",
"return",
"satisfies",
"static",
"super",
"switch",
"this",
"throw",
"true",
"try",
"type",
"typeof",
"undefined",
"var",
"void",
"while",
"yield",
];
const MERMAID_KEYWORDS = [
"flowchart",
"graph",
"subgraph",
"end",
"direction",
"TB",
"LR",
"RL",
"BT",
"classDef",
"class",
"style",
];
const JSON_KEYWORDS = ["true", "false", "null"];
export const KEYWORDS_BY_LANGUAGE: ReadonlyMap<string, ReadonlySet<string>> = new Map([
[TYPESCRIPT_LANGUAGE, new Set(SCRIPT_KEYWORDS)],
[JAVASCRIPT_LANGUAGE, new Set(SCRIPT_KEYWORDS)],
[MERMAID_LANGUAGE, new Set(MERMAID_KEYWORDS)],
[JSON_LANGUAGE, new Set(JSON_KEYWORDS)],
[YAML_LANGUAGE, new Set(JSON_KEYWORDS)],
]);
export const LINE_COMMENT_BY_LANGUAGE: ReadonlyMap<string, string> = new Map([
[TYPESCRIPT_LANGUAGE, DOUBLE_SLASH],
[JAVASCRIPT_LANGUAGE, DOUBLE_SLASH],
[YAML_LANGUAGE, HASH],
[MERMAID_LANGUAGE, DOUBLE_PERCENT],
]);
export const HEADING_LANGUAGES: ReadonlySet<string> = new Set([MARKDOWN_LANGUAGE, PAG_LANGUAGE]);
export const NONTERMINAL_LANGUAGES: ReadonlySet<string> = new Set([BNF_LANGUAGE, PAG_LANGUAGE]);
export const SHOUT_LANGUAGES: ReadonlySet<string> = new Set([PAG_LANGUAGE, BNF_LANGUAGE, MERMAID_LANGUAGE]);