2022-02-09 08:26:58 +08:00
|
|
|
module Examples.Syntax where
|
|
|
|
|
|
|
|
open import Agda.Builtin.Equality using (_≡_; refl)
|
|
|
|
open import FFI.Data.String using (_++_)
|
2022-03-03 06:02:51 +08:00
|
|
|
open import Luau.Syntax using (var; _$_; return; val; nil; function_is_end; local_←_; done; _∙_; _⟨_⟩)
|
2022-02-09 08:26:58 +08:00
|
|
|
open import Luau.Syntax.ToString using (exprToString; blockToString)
|
|
|
|
|
2022-02-12 09:03:26 +08:00
|
|
|
ex1 : exprToString(function "" ⟨ var "x" ⟩ is return (var "f" $ var "x") ∙ done end) ≡
|
|
|
|
"function(x)\n" ++
|
|
|
|
" return f(x)\n" ++
|
|
|
|
"end"
|
2022-02-09 08:26:58 +08:00
|
|
|
ex1 = refl
|
|
|
|
|
2022-03-03 06:02:51 +08:00
|
|
|
ex2 : blockToString(local var "x" ← (val nil) ∙ return (var "x") ∙ done) ≡
|
2022-02-12 09:03:26 +08:00
|
|
|
"local x = nil\n" ++
|
|
|
|
"return x"
|
2022-02-09 08:26:58 +08:00
|
|
|
ex2 = refl
|
|
|
|
|
2022-02-12 09:03:26 +08:00
|
|
|
ex3 : blockToString(function "f" ⟨ var "x" ⟩ is return (var "x") ∙ done end ∙ return (var "f") ∙ done) ≡
|
2022-02-09 08:26:58 +08:00
|
|
|
"local function f(x)\n" ++
|
|
|
|
" return x\n" ++
|
|
|
|
"end\n" ++
|
|
|
|
"return f"
|
|
|
|
ex3 = refl
|