Added bare-bones examples

This commit is contained in:
ajeffrey@roblox.com 2022-02-04 16:52:39 -06:00
parent 7112657c87
commit f736da826c
3 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,4 @@
module Examples where
import Examples.Syntax

View file

@ -0,0 +1,24 @@
module Examples.Syntax where
open import Agda.Builtin.Equality using (_≡_; refl)
open import FFI.Data.String using (_++_)
open import Luau.Syntax using (var; _$_; return; nil; function_⟨_⟩_end_)
open import Luau.Syntax.ToString using (exprToString; blockToString)
f = var "f"
x = var "x"
ex1 : exprToString(f $ x)
"f(x)"
ex1 = refl
ex2 : blockToString(return nil)
"return nil"
ex2 = refl
ex3 : blockToString(function "f" "x" return x end return f)
"function f(x)\n" ++
" return x\n" ++
"end\n" ++
"return f"
ex3 = refl

View file

@ -13,6 +13,7 @@ blockToString : String → Block → String
blockToString lb (function f x B end C) = blockToString lb (function f x B end C) =
"function " ++ f ++ "(" ++ x ++ ")" ++ lb ++ "function " ++ f ++ "(" ++ x ++ ")" ++ lb ++
" " ++ (blockToString (lb ++ " ") B) ++ lb ++ " " ++ (blockToString (lb ++ " ") B) ++ lb ++
"end" ++ lb ++
blockToString lb C blockToString lb C
blockToString lb (local x M B) = blockToString lb (local x M B) =
"local " ++ x ++ " = " ++ (exprToString M) ++ lb ++ "local " ++ x ++ " = " ++ (exprToString M) ++ lb ++