refactored MyRuleNode to use es6 class

This commit is contained in:
Camilo Roca 2020-03-20 14:52:24 +01:00
parent 176f852bf1
commit 1922a3744e
1 changed files with 12 additions and 9 deletions

View File

@ -188,18 +188,21 @@ walker.walk(new this.LeafListener(), <s>);
TreeNodeWithAltNumField(X) ::= <<
@parser::header {
MyRuleNode = function(parent, invokingState) {
antlr4.ParserRuleContext.call(this, parent, invokingState);
class MyRuleNode extends antlr4.ParserRuleContext {
constructor(parent, invokingState) {
super(parent, invokingState);
this.altNum = 0;
}
this.altNum = 0;
return this;
getAltNumber() {
return this.altNum;
}
setAltNumber(altNumber){
this.altNum = altNumber;
}
};
MyRuleNode.prototype = Object.create(antlr4.ParserRuleContext.prototype);
MyRuleNode.prototype.constructor = MyRuleNode;
MyRuleNode.prototype.getAltNumber = function() { return this.altNum; }
MyRuleNode.prototype.setAltNumber = function(altNumber) { this.altNum = altNumber; }
}
>>