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
Tiscs authored Sep 23, 2024
2 parents 7258807 + 2a7904a commit 42511ee
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 20 deletions.
19 changes: 2 additions & 17 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:11 AS builder
FROM eclipse-temurin:21 AS builder

WORKDIR /opt/antlr4

Expand All @@ -14,23 +14,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install maven git -
&& mvn -DskipTests install --projects tool --also-make \
&& mv ./tool/target/antlr4-*-complete.jar antlr4-tool.jar

FROM eclipse-temurin:11-jre

ARG user=appuser
ARG group=appuser
ARG uid=1000
ARG gid=1000

RUN adduser \
--disabled-password \
--gecos "" \
--home "$(pwd)" \
--no-create-home \
--uid "${uid}" \
"${user}"
FROM eclipse-temurin:21-jre

COPY --from=builder /opt/antlr4/antlr4/antlr4-tool.jar /usr/local/lib/
WORKDIR /work
ENTRYPOINT ["java", "-Xmx500M", "-cp", "/usr/local/lib/antlr4-tool.jar", "org.antlr.v4.Tool"]


Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
writeln(s) ::= <<console.log(<s> || '');>>
write(s) ::= <<process.stdout.write(<s> || '');>>
writeln(s) ::= <<console.log(<s>);>>
write(s) ::= <<process.stdout.write(<s>);>>
writeList(s) ::= <<console.log(<s; separator="+">);>>

False() ::= "false"
Expand Down
3 changes: 2 additions & 1 deletion runtime/JavaScript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
},
"scripts": {
"build": "webpack",
"test": "jasmine",
"test": "jasmine && npm run test:builds",
"test:builds": "bash test-builds.sh",
"coverage": "c8 jasmine",
"lint": "eslint src/antlr4/"
},
Expand Down
3 changes: 3 additions & 0 deletions runtime/JavaScript/spec/imports/builds/node-cjs-ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules

package-lock.json
5 changes: 5 additions & 0 deletions runtime/JavaScript/spec/imports/builds/node-cjs-ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { CharStream } = require("antlr4");

const cs = new CharStream("OK");

console.log(cs.toString());
18 changes: 18 additions & 0 deletions runtime/JavaScript/spec/imports/builds/node-cjs-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "test-import-node-cjs-ts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "commonjs",
"scripts": {
"test": "bash test.sh"
},
"author": "",
"license": "ISC",
"dependencies": {
"antlr4": "file:../../../.."
},
"devDependencies": {
"typescript": "^5.4.3"
}
}
19 changes: 19 additions & 0 deletions runtime/JavaScript/spec/imports/builds/node-cjs-ts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

tsconfigFiles=(
"tsconfig.node.commonjs.json"
)

failure=0

for tsconfig in "${tsconfigFiles[@]}"; do
echo -n "$tsconfig "

./node_modules/.bin/tsc -p $tsconfig || { failure=1 ; echo "FAIL tsc: $tsconfig"; }
result=$(node ./tsOutput/index.js)
[[ $result == "OK" ]] && echo "OK"
[[ $result != "OK" ]] && { failure=1 ; echo "FAIL loading runtime with config: $tsconfig"; }
rm -rf ./tsOutput
done

exit $failure
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"baseUrl": ".",
"skipLibCheck": true,
"outDir": "./tsOutput",
"module": "commonjs",
"moduleResolution": "node"
},
"include": ["index.ts"],
}
3 changes: 3 additions & 0 deletions runtime/JavaScript/spec/imports/builds/node-esm-ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules

package-lock.json
5 changes: 5 additions & 0 deletions runtime/JavaScript/spec/imports/builds/node-esm-ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CharStream } from "antlr4";

const cs = new CharStream("OK");

console.log(cs.toString());
18 changes: 18 additions & 0 deletions runtime/JavaScript/spec/imports/builds/node-esm-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "test-import-node-esm-ts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "bash test.sh"
},
"author": "",
"license": "ISC",
"dependencies": {
"antlr4": "file:../../../.."
},
"devDependencies": {
"typescript": "^5.4.3"
}
}
20 changes: 20 additions & 0 deletions runtime/JavaScript/spec/imports/builds/node-esm-ts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

tsconfigFiles=(
"tsconfig.node16.json"
"tsconfig.bundler.es2022.json"
)

failure=0

for tsconfig in "${tsconfigFiles[@]}"; do
echo -n "$tsconfig "

./node_modules/.bin/tsc -p $tsconfig || { failure=1 ; echo "FAIL tsc: $tsconfig"; }
result=$(node ./tsOutput/index.js)
[[ $result == "OK" ]] && echo "OK"
[[ $result != "OK" ]] && { failure=1 ; echo "FAIL loading runtime with config: $tsconfig"; }
rm -rf ./tsOutput
done

exit $failure
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"baseUrl": ".",
"skipLibCheck": true,
"outDir": "./tsOutput",
"module": "es2022",
"moduleResolution": "bundler"
},
"include": ["index.ts"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"baseUrl": ".",
"skipLibCheck": true,
"outDir": "./tsOutput",
"module": "node16",
"moduleResolution": "node16"
},
"include": ["index.ts"],
}
6 changes: 6 additions & 0 deletions runtime/JavaScript/test-builds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

cd spec/imports/builds/node-esm-ts
npm run test
cd ../node-cjs-ts
npm run test

0 comments on commit 42511ee

Please sign in to comment.