Gremlins
A tiny (under 20kb) compiler for a TypeScript-inspired language that compiles to EVM bytecode for querying blockchain data.
Screenshots



Problem Statement
A simple compiler TypeScript-inspired language that compiles to EVM bytecode for querying blockchain data.The bison grammar is compiled using Jison to create the parser, which generates the Abstract Syntax Tree.Code generation uses a simple visitor and ASM builder.The ASM Builder still has a lot of work and will help simplify this project, as the amount of hand-written, low-level EVM byte code required for this proved to be too much for me to complete this project. :)The ASM Building however, will be the most useful part of this project and will help make future languages easier to during codegen. It has a higher-level interface similar to Yul, except is a JavaScript class that constructs the EVM tree while creating the program.
Solution
The only technologies are really just Jison (a JavaScript variant of Bison) to construct the compiler using a standard grammar file.The grammar file is based largely on the C-grammar for its precedent specification of expressions, with extensions for Solidity Interfaces and TypeScript-style types.The docs in the GitHub repo contain more information about the runtime and calling conventions.
Hackathon
ETHGlobal New York
2024
Contributors
- ricmoo
18 contributions