Phase 2: schema-aware typed compilation in FreshMarker

The previous post looked at the Stage 1 (untyped) compiler and finished with an honest observation: Stage 1 removes fragment-dispatch overhead but still evaluates every expression through TemplateObject. This third and final post explains how the Stage 2 compiler uses a TemplateTypeSchema to emit raw Java that talks directly to your data model — and how that unlocks the ~2.5× AOT speedup from the benchmark chart in the first post.

Eigene Parser mit JavaCC 21 erstellen

Der Java Compiler Compiler (kurz JavaCC) ist ein Parser Generator für die Java Entwicklung. Aus einer bestehenden Grammatik erstellt dieses Programm Java Code, mit dem Eingaben gegen diese Grammatik geprüft und verarbeitet werden können. Bei JavaCC handelt es sich um einen alten Bekannten, schon 2002 nutzte ich das Tool für die CSS2 Verarbeitung in einem embedded HTML Browser.