Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

depricate some methods #4562

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion runtime/JavaScript/src/antlr4/Lexer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export declare class Lexer extends Recognizer<number> {
nextToken(): Token;
skip(): void;
more(): void;
more(m: number): void;
setMode(m: number): void;
getMode(): number;
getModeStack(): number[];
pushMode(m: number): void;
popMode(): number;
emitToken(token: Token): void;
Expand Down
22 changes: 19 additions & 3 deletions runtime/JavaScript/src/antlr4/Lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,32 @@ export default class Lexer extends Recognizer {
this._type = Lexer.MORE;
}

/**
* @deprecated since ANTLR 4.13.2; use setMode instead
*/
mode(m) {
console.warn("Calling deprecated method in Lexer class: mode(...)");
setMode(m);
}

setMode(m) {
this._mode = m;
}

getMode() {
return this._mode;
}

getModeStack() {
return this._modeStack;
}

pushMode(m) {
if (this._interp.debug) {
console.log("pushMode " + m);
}
this._modeStack.push(this._mode);
this.mode(m);
this.setMode(m);
}

popMode() {
Expand All @@ -188,7 +204,7 @@ export default class Lexer extends Recognizer {
if (this._interp.debug) {
console.log("popMode back to " + this._modeStack.slice(0, -1));
}
this.mode(this._modeStack.pop());
this.setMode(this._modeStack.pop());
return this._mode;
}

Expand Down Expand Up @@ -252,7 +268,7 @@ export default class Lexer extends Recognizer {
const stop = this._input.index;
const text = this._input.getText(start, stop);
const msg = "token recognition error at: '" + this.getErrorDisplay(text) + "'";
const listener = this.getErrorListenerDispatch();
const listener = this.getErrorListener();
listener.syntaxError(this, null, this._tokenStartLine,
this._tokenStartColumn, msg, e);
}
Expand Down
5 changes: 5 additions & 0 deletions runtime/JavaScript/src/antlr4/Parser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {ParserATNSimulator} from "./atn";
import {Token} from "./Token";
import {ParserRuleContext} from "./context";
import {Printer} from "./utils";
import {ParseTreeListener} from "./tree";

export declare class Parser extends Recognizer<Token> {

Expand All @@ -24,6 +25,10 @@ export declare class Parser extends Recognizer<Token> {
constructor(input: TokenStream);
match(ttype: number): Token;
matchWildcard(): Token;
getParseListeners(): ParseTreeListener[];
addParseListener(listener: ParseTreeListener): void;
removeParseListener(listener: ParseTreeListener): void;
removeParseListeners(): void;
consume(): Token;
enterRule(localctx: ParserRuleContext, state: number, ruleIndex: number): void;
exitRule() : void;
Expand Down
2 changes: 1 addition & 1 deletion runtime/JavaScript/src/antlr4/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export default class Parser extends Recognizer {
this._syntaxErrors += 1;
const line = offendingToken.line;
const column = offendingToken.column;
const listener = this.getErrorListenerDispatch();
const listener = this.getErrorListener();
listener.syntaxError(this, offendingToken, line, column, msg, err);
}

Expand Down
3 changes: 3 additions & 0 deletions runtime/JavaScript/src/antlr4/Recognizer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export declare class Recognizer<TSymbol> {

removeErrorListeners(): void;
addErrorListener(listener: ErrorListener<TSymbol>): void;
getErrorListener(): ErrorListener<TSymbol>;
getLiteralNames(): string[];
getSymbolicNames(): string[];
}
8 changes: 8 additions & 0 deletions runtime/JavaScript/src/antlr4/Recognizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,15 @@ export default class Recognizer {
return "'" + s + "'";
}

/**
* @deprecated since ANTLR 4.13.2; use getErrorListener instead
*/
getErrorListenerDispatch() {
console.warn("Calling deprecated method in Recognizer class: getErrorListenerDispatch()");
return this.getErrorListener();
}

getErrorListener() {
return new ProxyErrorListener(this._listeners);
}

Expand Down
6 changes: 4 additions & 2 deletions runtime/JavaScript/src/antlr4/Token.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {CharStream} from "./CharStream";
import { TokenSource } from "./TokenSource";
import { CharStream } from "./CharStream";

export declare class Token {

static INVALID_TYPE: number;
static EOF: number;

static DEFAULT_CHANNEL: number;
static HIDDEN_CHANNEL: number;

Expand All @@ -18,5 +19,6 @@ export declare class Token {

clone(): Token;
cloneWithType(type: number): Token;
getTokenSource(): TokenSource;
getInputStream(): CharStream;
}
2 changes: 1 addition & 1 deletion runtime/JavaScript/src/antlr4/action/LexerModeAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class LexerModeAction extends LexerAction {
* value provided by {@link //getMode}.</p>
*/
execute(lexer) {
lexer.mode(this.mode);
lexer.setMode(this.mode);
}

updateHashCode(hash) {
Expand Down
6 changes: 3 additions & 3 deletions runtime/JavaScript/src/antlr4/atn/ParserATNSimulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ export default class ParserATNSimulator extends ATNSimulator {
", input=" + this.parser.getTokenStream().getText(interval));
}
if (this.parser!==null) {
this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser, dfa, startIndex, stopIndex, conflictingAlts, configs);
this.parser.getErrorListener().reportAttemptingFullContext(this.parser, dfa, startIndex, stopIndex, conflictingAlts, configs);
}
}

Expand All @@ -1713,7 +1713,7 @@ export default class ParserATNSimulator extends ATNSimulator {
", input=" + this.parser.getTokenStream().getText(interval));
}
if (this.parser!==null) {
this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser, dfa, startIndex, stopIndex, prediction, configs);
this.parser.getErrorListener().reportContextSensitivity(this.parser, dfa, startIndex, stopIndex, prediction, configs);
}
}

Expand All @@ -1726,7 +1726,7 @@ export default class ParserATNSimulator extends ATNSimulator {
", input=" + this.parser.getTokenStream().getText(interval));
}
if (this.parser!==null) {
this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
this.parser.getErrorListener().reportAmbiguity(this.parser, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
}
}
}
Loading