How skinny85/graalvm-truffle-tutorial works
Project type and purpose
• This is a compiler/language‐implementation tutorial, not a web or full‐stack app.
• It implements “EasyScript,” a small JavaScript subset, on top of GraalVM’s Truffle framework.
• The README confirms it is a series of Gradle submodules (part-01…part-16), each adding features (parsing, globals, functions, arrays, classes, exceptions, debugger, benchmarking).
File structure
• Top‐level is a Gradle multi‐project build (settings.gradle, build.gradle, gradle wrapper, .github/workflows).
• Each part-XX folder is a Gradle submodule with its own build.gradle, src/main/java, src/main/antlr (from part-04 onward), and src/jmh in benchmark modules (part-09+).
• Key patterns:
• ANTLR grammars (EasyScript.g4) drive parser generation.
• Java packages com.endoflineblog.truffle.part_XX contain:
– TruffleLanguage subclass (EasyScriptTruffleLanguage)
– Parser wrapper (EasyScriptTruffleParser)
– LanguageContext (EasyScriptLanguageContext)
– TypeSystem definitions
– AST nodes (root, exprs, stmts, specialized nodes)
– Runtime objects (GlobalScopeObject, FunctionObject, ArrayObject, etc.)
• JMH benchmarks in src/jmh for measuring interpreter performance.
• Test code in src/test for unit tests of parsing, execution, and benchmarks.
README for additional insights
• The tutorial’s structure: each part builds on the previous, adding new language features.
• Dependencies: GraalVM SDK (Truffle API), ANTLR, JMH, JUnit.
• Build and run via Gradle wrapper.