Slang is a small educational programming language implemented in Java/Kotlin with ANTLR for parsing. This README explains how to get the codebase running locally and how to start contributing.
- Install prerequisites:
- JDK 21 or later.
- No global Gradle required; use the included wrapper
./gradlew.
- Clone the repository:
git clone https://github.com/jpksh90/Slang.git cd Slang - Build the project (this generates ANTLR sources and compiles):
./gradlew clean build- Run tests:
./gradlew test- File > Open... > select the repository root (or the
build.gradlefile). - Enable Gradle auto-import when prompted.
- If the IDE does not recognize generated sources, run:
./gradlew generateGrammarSource ./gradlew build
- To run or debug the REPL or the main application, create an Application run configuration that points to the appropriate
mainclass or use the Gradle taskrun.
- Run the REPL:
./slang repl
# Or using Gradle:
./gradlew run --console=plain --quiet --args="repl"-
Run a Slang program:
./slang <input-file> # Example: ./slang src/test/resources/sum_prod.slang
-
Output HLIR representation:
# To stdout: ./slang --hlir src/test/resources/sum_prod.slang # To file: ./slang --hlir src/test/resources/sum_prod.slang -o output.yaml
-
Clean build artifacts:
./gradlew cleansrc/main/antlr/Slang.g4— ANTLR grammar.src/main/kotlin/slast/ast/AstBuilder.kt— AST builder from parse tree.build/generated-src/antlr/main/SlangParser.java— generated parser (do not edit).src/test/resources/— example.slangprograms used by tests.
- Grammar changes: edit
src/main/antlr/Slang.g4and regenerate:
./gradlew generateGrammarSource
./gradlew build- Tests exercise language features. Run them frequently when changing parser/AST/IR.
- Keep generated parser files out of manual edits; regenerate from the .g4 source.
- Create a feature branch from
main. - Ensure
./gradlew buildand./gradlew testpass locally before opening a PR. - Use small, focused commits and describe the intent in the PR.
- If IntelliJ can't see generated sources: run
./gradlew generateGrammarSourcethen refresh Gradle projects. - If Gradle fails due to JDK version, confirm
java -versionshows JDK 21+ and adjustIDEA Project SDKif needed.
- Open issues or pull requests on GitHub at the repository root.
- AI was heavily used to generate the code.