Skip to content

Commit

Permalink
Merge branch 'antlr:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
RobEin authored Mar 5, 2024
2 parents ee4c88f + 1b3150b commit 9193b09
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 11 deletions.
2 changes: 0 additions & 2 deletions doc/javascript-target.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ Once you've generated the lexer and/or parser code, you need to download the run

The JavaScript runtime is [available from npm](https://www.npmjs.com/package/antlr4).

If you can't use npm, the JavaScript runtime is also available from the ANTLR web site [download section](http://www.antlr.org/download/index.html). The runtime is provided in the form of source code, so no additional installation is required.

We will not document here how to refer to the runtime from your project, since this would differ a lot depending on your project type and IDE.

## How do I get the runtime in my browser?
Expand Down
4 changes: 2 additions & 2 deletions runtime/JavaScript/spec/rewriter/TokenStreamRewriterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import calc from "./generatedCode/calc.js";
* @param {string} input
*/
function getRewriter(lexerClass, input) {
const chars = new antlr4.InputStream(input);
const chars = antlr4.CharStreams.fromString(input);
const lexer = new lexerClass(chars);
const tokens = new antlr4.CommonTokenStream(lexer);
tokens.fill();
Expand Down Expand Up @@ -385,7 +385,7 @@ describe("TokenStreamRewriter", () => {

it("throws an error if second replace operation overlaps the first one on the left", () => {
// Arrange
const chars = new antlr4.InputStream("abcccba");
const chars = antlr4.CharStreams.fromString("abcccba");
const lexer = new abc(chars);
const tokens = new antlr4.CommonTokenStream(lexer);
tokens.fill();
Expand Down
2 changes: 1 addition & 1 deletion runtime/JavaScript/src/antlr4/Lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default class Lexer extends Recognizer {
this.notifyListeners(e); // report error
this.recover(e);
} else {
console.log(e.stack);
console.log(e.stack);
throw e;
}
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/JavaScript/src/antlr4/index.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { default as Utils } from './utils/index.js';
import Token from './Token.js';
import CommonToken from './CommonToken.js';
import InputStream from './InputStream.js';
import CharStream from './InputStream.js';
import CharStream from './CharStream.js';
import FileStream from './FileStream.js';
import CommonTokenStream from './CommonTokenStream.js';
import Lexer from './Lexer.js';
Expand Down Expand Up @@ -57,5 +57,5 @@ export {
RuleNode, TerminalNode, ParseTreeWalker, RuleContext, ParserRuleContext, Interval, IntervalSet,
PredictionMode, LL1Analyzer, ParseTreeListener, ParseTreeVisitor, ATN, ATNDeserializer, PredictionContextCache, LexerATNSimulator, ParserATNSimulator, DFA,
RecognitionException, NoViableAltException, FailedPredicateException, ErrorListener, DiagnosticErrorListener, BailErrorStrategy, DefaultErrorStrategy,
arrayToString
arrayToString, TokenStreamRewriter
}
4 changes: 2 additions & 2 deletions runtime/JavaScript/src/antlr4/index.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { default as Utils } from './utils/index.js';
import Token from './Token.js';
import CommonToken from './CommonToken.js';
import InputStream from './InputStream.js';
import CharStream from './InputStream.js';
import CharStream from './CharStream.js';
import CommonTokenStream from './CommonTokenStream.js';
import Lexer from './Lexer.js';
import Parser from './Parser.js';
Expand Down Expand Up @@ -56,5 +56,5 @@ export {
RuleNode, TerminalNode, ParseTreeWalker, RuleContext, ParserRuleContext, Interval, IntervalSet,
PredictionMode, LL1Analyzer, ParseTreeListener, ParseTreeVisitor, ATN, ATNDeserializer, PredictionContextCache, LexerATNSimulator, ParserATNSimulator, DFA,
RecognitionException, NoViableAltException, FailedPredicateException, ErrorListener, DiagnosticErrorListener, BailErrorStrategy, DefaultErrorStrategy,
arrayToString
arrayToString, TokenStreamRewriter
}
2 changes: 1 addition & 1 deletion runtime/Python3/src/antlr4/atn/ATNDeserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def deserialize(self, data : [int]):
def checkVersion(self):
version = self.readInt()
if version != SERIALIZED_VERSION:
raise Exception("Could not deserialize ATN with version " + str(version) + " (expected " + str(SERIALIZED_VERSION) + ").")
raise Exception("Could not deserialize ATN with version {} (expected {}).".format(ord(version), SERIALIZED_VERSION))

def readATN(self):
idx = self.readInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Parser(parser, funcs, atn, sempredFuncs, superClass) ::= <<
>>

Parser_(parser, funcs, atn, sempredFuncs, ctor, superClass) ::= <<
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"})
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"})
public class <parser.name> extends <superClass; null="Parser"> {
static { RuntimeMetaData.checkVersion("<file.ANTLRVersion>", RuntimeMetaData.VERSION); }

Expand Down

0 comments on commit 9193b09

Please sign in to comment.