antlr-ng
Version:
Next generation ANTLR Tool
74 lines (73 loc) • 2.92 kB
TypeScript
import type { IST } from "stringtemplate4ts";
import { type STGroup } from "stringtemplate4ts";
import { Tool } from "../Tool.js";
import { CodeGenerator } from "../codegen/CodeGenerator.js";
import { Grammar } from "./Grammar.js";
/**
* Given a grammar file, show the dependencies on .tokens etc... Using ST, emit a simple "make compatible" list of
* dependencies. For example, combined grammar T.g (no token import) generates:
*
* TParser.java : T.g
* T.tokens : T.g
* TLexer.java : T.g
*
* If we are using the listener pattern (-listener on the command line) then we add:
*
* TListener.java : T.g
* TBaseListener.java : T.g
*
* If we are using the visitor pattern (-visitor on the command line) then we add:
*
* TVisitor.java : T.g
* TBaseVisitor.java : T.g
*
* If "-lib libDir" is used on command-line with -depend and option tokenVocab=A in grammar, then include the path
* like this:
*
* T.g: libDir/A.tokens
*
* Pay attention to -o as well:
*
* output-dir/TParser.java : T.g
*
* So this output shows what the grammar depends on *and* what it generates.
*
* Operate on one grammar file at a time. If given a list of .g on the command-line with -depend, just emit the
* dependencies. The grammars may depend on each other, but the order doesn't matter. Build tools, reading in this
* output, will know how to organize it.
*
* This code was obvious until I removed redundant "./" on front of files and had to escape spaces in filenames :(
*
* I literally copied from v3 so might be slightly inconsistent with the v4 code base.
*/
export declare class BuildDependencyGenerator {
private libDirectory?;
private generateListeners?;
private generateVisitors?;
protected tool: Tool;
protected g: Grammar;
protected generator: CodeGenerator;
protected templates?: STGroup;
constructor(tool: Tool, g: Grammar, libDirectory?: string | undefined, generateListeners?: boolean | undefined, generateVisitors?: boolean | undefined);
/**
* @returns a list of URL objects that name files ANTLR will emit from T.g.
*/
getGeneratedFileList(): URL[];
getOutputFile(fileName: string): URL;
/**
* @returns a list of urls that name files ANTLR will read to process T.g. This can be .tokens files if the
* grammar uses the tokenVocab option as well as any imported grammar files.
*/
getDependenciesFileList(): URL[];
/**
* Return a list of File objects that name files ANTLR will read to process T.g; This can only be .tokens files
* and only if they use the tokenVocab option.
*
* @returns List of dependencies other than imported grammars
*/
getNonImportDependenciesFileList(): URL[];
getDependencies(): IST;
loadDependencyTemplates(): void;
getGenerator(): CodeGenerator;
groomQualifiedFileName(outputDir: string, fileName: string): string;
}