Skip to content

Commit

Permalink
Added extra parameters option in vscode settings for ANTLR4 jar
Browse files Browse the repository at this point in the history
Fixes #69
  • Loading branch information
mike-lischke committed Nov 20, 2019
1 parent 3507cd8 commit b0f7ebd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@
"type": "boolean",
"default": false,
"description": "Also create visitors on code generation"
},
"alternativeJar": {
"type": "string",
"description": "Path to a Java jar file to be used for parser generation"
},
"additionalParameters": {
"type": "string",
"description": "Any other commandline parameters you want to send to the ANTLR4 jar"
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion src/backend/SourceContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,11 @@ export class SourceContext {
parameters.push(genListener ? "-listener" : "-no-listener");
parameters.push(options.visitors === true ? "-visitor" : "-no-visitor");
parameters.push("-Xexact-output-dir"); // Available starting with 4.7.2.

if (options.additionalParameters) {
parameters.push(options.additionalParameters);
}

dependencies.add(thisRef); // Needs this also in the error parser.

let fileList: string[] = [];
Expand Down Expand Up @@ -818,7 +823,7 @@ export class SourceContext {
thisRef.setupInterpreters(options.outputDir);
resolve(fileList);
} else {
reject(buffer); // Treat this as non-grammar error (e.g. Java exception).
reject(buffer); // Treat this as non-grammar output (e.g. Java exception).
}
});
});
Expand Down
10 changes: 6 additions & 4 deletions src/backend/facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,17 @@ export class ATNGraphData {
* Options used by the parser files generation.
*/
export interface GenerationOptions {
baseDir?: string; // The folder in which to run the generation process. Should be an absolute path for predictable results.
baseDir?: string; // The folder in which to run the generation process.
// Should be an absolute path for predictable results. Used internally only.
libDir?: string; // Search path for the ANTLR tool.
outputDir?: string; // The folder where to place generated files in (relative to baseDir or absolute). (default: grammar dir)
package?: string; // Package or namespace name for generated files. (default: none)
language?: string; // The target language for the generated files. (default: what's given in the grammar or Java)
listeners?: boolean; // Generate listener files if set. (default: true)
visitors?: boolean; // Generate visitor files if set. (default: false)
loadOnly?: boolean; // Don't generate anything. Just try to load interpreter data and do interpreter setup.
alternativeJar?: string; // Use this jar for work instead of the built-in one(s).
alternativeJar?: string; // Use this jar for work instead of the built-in one(s).
additionalParameters?: string; // Any additional parameter you want to send to ANTLR4 for generation (e.g. "-XdbgST").
};

/**
Expand Down Expand Up @@ -470,7 +472,7 @@ export class AntlrFacade {
*
* @param fileName The grammar file.
*/
public getLexerVocabulary(fileName: string): Vocabulary | undefined{
public getLexerVocabulary(fileName: string): Vocabulary | undefined {
let context = this.getContext(fileName);
return context.getVocabulary();
}
Expand Down Expand Up @@ -525,7 +527,7 @@ export class AntlrFacade {
return context.getDiagnostics();
};

public ruleFromPosition(fileName: string, column: number, row: number): [string | undefined, number | undefined ]{
public ruleFromPosition(fileName: string, column: number, row: number): [string | undefined, number | undefined] {
let context = this.getContext(fileName);
return context.ruleFromPosition(column, row);
}
Expand Down
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ export function activate(context: ExtensionContext) {
libDir: workspace.getConfiguration("antlr4.generation")["importDir"],
outputDir: outputDir,
listeners: false,
visitors: false
visitors: false,
alternativeJar: workspace.getConfiguration("antlr4.generation")["alternativeJar"],
additionalParameters: workspace.getConfiguration("antlr4.generation")["additionalParameters"]
};

if (externalMode) {
Expand Down

0 comments on commit b0f7ebd

Please sign in to comment.