mcchatman8009 / antlr4-tool

A useful Antlr4 tool with full TypeScript support
Other
36 stars 20 forks source link

Sub-rules are missing in Parser.d.ts #22

Open fabien0102 opened 5 years ago

fabien0102 commented 5 years ago

Hi! First of all, thank for this amazing package, it's very nice to have antlr available in browser side 😃

I just have some little mismatches between the PslParser.js and the PslParser.d.ts files.

Here my repro steps and bit more details:

Command

 antlr4-tool -l ts -o src/parser Grammar.g4

The grammar

grammar Grammar;

schema: 'schema' (schemaParams);
schemaParams: '(' (schemaParam (',' schemaParam)*)? ')';
schemaParam: ('a' | 'b' | 'c')*;

GrammarParser.js

SchemaParamsContext.prototype.schemaParam = function(i) {
    if(i===undefined) {
        i = null;
    }
    if(i===null) {
        return this.getTypedRuleContexts(SchemaParamContext);
    } else {
        return this.getTypedRuleContext(SchemaParamContext,i);
    }
};

GrammarParser.d.ts (actual)

export declare class SchemaParamsContext extends ParserRuleContext {

}

GrammarParser.d.ts (expected)

export declare class SchemaParamsContext extends ParserRuleContext {
+    schemaParam(): SchemaParamContext;
}
mcchatman8009 commented 5 years ago

@fabien0102 I'll see what I can do to fix these issues soon. Thanks again your patience and for reporting.