Skip to content

NiccoMlt/setup-antlr4

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Action to setup ANTLR 4.8

Test action

This action pulls complete ANTLR 4.8 jar and defines Antlr4ToolPath environment variable pointing to it. Some tools (i.e. Antlr4BuildTasks) require this kind of configuration; for this kind of usage, it also declares the required JAVA_EXEC variable if JAVA_HOME is available.

Usage:

Example:

steps:
- uses: actions/checkout@v2
- uses: NiccoMlt/setup-antlr4@v0.0.6

You probably also want to add actions/setup-java to run the jar correctly.

Improvements

Script definition

The action also adds the jar in PATH, but this is pretty much useless currently. You can simply add your own script like explained in the official documentation:

antlr4:

#!/bin/sh
java -cp "$Antlr4ToolPath:$CLASSPATH" org.antlr.v4.Tool $@

grun:

#!/bin/sh
java -cp ".:$Antlr4ToolPath:$CLASSPATH" org.antlr.v4.gui.TestRig $@

antlr4.bat:

java -cp "%Antlr4ToolPath%;%CLASSPATH%" org.antlr.v4.Tool %*

grun.bat:

java -cp ".;%Antlr4ToolPath%;%CLASSPATH%" org.antlr.v4.gui.TestRig %*

antlr4.ps1:

java -cp "$Env:Antlr4ToolPath$([System.IO.Path]::PathSeparator)$Env:CLASSPATH" org.antlr.v4.Tool $args

grun.ps1:

java -cp ".$([System.IO.Path]::PathSeparator)$Env:Antlr4ToolPath$([System.IO.Path]::PathSeparator)$Env:CLASSPATH" org.antlr.v4.gui.TestRig $args

In a future version, I will probably add also these scripts to PATH.

ANTLR version

Currently, this action only fetches latest 4.8 version. In a future version, I will probably enable different download options.