C♭ Demo
Mix.install([
{:cflat, "~> 0.2.4"},
{:kino, "~> 0.14.2"}
])
Input Code
kino = Kino.Input.textarea("Insert C♭ code:", default: "int i = 42;", monospace: true)
Parse
ast =
kino
|> Kino.Input.read()
|> Cflat.tokenize()
|> Cflat.parse()
Abstract Syntax Tree
ast
|> Cflat.SyntaxTree.as_mermaid()
|> Kino.Mermaid.new()
Evaluate
ast
|> Cflat.Interpreter.evaluate()