Syntax Bridge is a compiler and transpiler built for a custom educational programming language. This project demonstrates the implementation of a full language processing pipeline - from lexical analysis and parsing (using ANTLR4) to semantic analysis, Java code generation, and dynamic compilation.
It allows you to write code in a simplified syntax and compiles it directly into executable Java byte-code.
- Variable Declaration & Assignment:
var ID : type ;(int,float)ID := expr ;
- Control Flow:
if (expr) { ... } [else { ... }]/endwhile (expr) { ... }
- Functions: Define and call custom functions with parameters:
func ID(params) { ... }ID(args);
- Print Statements:
print(expr); - Expressions & Operators:
- Arithmetic:
+,-,*,/ - Unary:
-expr - Relational:
<,<=,>,>= - Equality:
==,!= - Grouping:
(expr) - Casts:
(type) expr - Literals: numbers, strings, identifiers
- Arithmetic:
- Comments:
- Line:
// ... - Block:
/* ... */
- Line:
- Language: Java 17+
- Build Tool: Maven
- Parser Generator: ANTLR4
- Testing: JUnit 5
Ensure you have the following installed:
- Java JDK 17 (or higher)
- Maven (3.8+)
This will generate the ANTLR sources (Parser/Lexer) and compile the project.
mvn clean installYou can run the main application via your IDE or:
mvn exec:java -Dexec.mainClass="org.example.Main"mvn exec:java "-Dexec.mainClass=org.example.Main"The project includes unit tests for parsing, generation, and compilation logic.
mvn test- Lexer/Parser: ANTLR4 reads the .g4 grammar file and generates the EduLangLexer and EduLangParser.
- Code Generator: CodeGenerator.java visits the parse tree and constructs a standard Java String representing the program.
- Compiler Service: Takes the generated string, writes it to a file, and invokes the system Java Compiler.
- Java Execution: The resulting bytecode is executed.