@scinorandex/sparse
Version:
Yet another parser generator
28 lines (27 loc) • 893 B
TypeScript
import { Slex, Token } from "@scinorandex/slex";
import { Result } from "./utils/Result";
export type Production = {
lhs: GrammarToken;
rhs: {
type: "terminal" | "variable";
token: GrammarToken;
}[];
};
export type GrammarTokenMetadata = {};
export declare enum GrammarTokenType {
PRODUCTION_NAME = 0,
TOKEN_NAME = 1,
COLON = 2,
SEMICOLON = 3,
EOF = 4
}
export type GrammarToken = Token<GrammarTokenType, GrammarTokenMetadata>;
export declare const grammarLexerGenerator: Slex<GrammarTokenType, GrammarTokenMetadata>;
interface LexerInterface {
peekNextToken(): GrammarToken;
getNextToken(): GrammarToken;
hasNextToken(): boolean;
}
export declare const tryBuildProductions: (lexer: LexerInterface | string) => Result<Production[]>;
export declare const buildProductions: (lexer: LexerInterface | string) => Production[];
export {};