2022-02-09 00:26:58 +00:00
|
|
|
module Examples.Syntax where
|
|
|
|
|
|
|
|
open import Agda.Builtin.Equality using (_≡_; refl)
|
|
|
|
open import FFI.Data.String using (_++_)
|
2022-02-09 23:14:29 +00:00
|
|
|
open import Luau.Syntax using (var; _$_; return; nil; function_⟨_⟩_end; done; _∙_)
|
2022-02-09 00:26:58 +00:00
|
|
|
open import Luau.Syntax.ToString using (exprToString; blockToString)
|
|
|
|
|
|
|
|
f = var "f"
|
|
|
|
x = var "x"
|
|
|
|
|
|
|
|
ex1 : exprToString(f $ x) ≡
|
|
|
|
"f(x)"
|
|
|
|
ex1 = refl
|
|
|
|
|
2022-02-09 23:14:29 +00:00
|
|
|
ex2 : blockToString(return nil ∙ done) ≡
|
2022-02-09 00:26:58 +00:00
|
|
|
"return nil"
|
|
|
|
ex2 = refl
|
|
|
|
|
2022-02-09 23:14:29 +00:00
|
|
|
ex3 : blockToString(function "f" ⟨ "x" ⟩ return x ∙ done end ∙ return f ∙ done) ≡
|
2022-02-09 00:26:58 +00:00
|
|
|
"local function f(x)\n" ++
|
|
|
|
" return x\n" ++
|
|
|
|
"end\n" ++
|
|
|
|
"return f"
|
|
|
|
ex3 = refl
|