mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Added bare-bones examples
This commit is contained in:
parent
7112657c87
commit
f736da826c
3 changed files with 29 additions and 0 deletions
4
prototyping/Examples.agda
Normal file
4
prototyping/Examples.agda
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
module Examples where
|
||||||
|
|
||||||
|
import Examples.Syntax
|
||||||
|
|
24
prototyping/Examples/Syntax.agda
Normal file
24
prototyping/Examples/Syntax.agda
Normal 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
|
|
@ -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 ++
|
||||||
|
|
Loading…
Add table
Reference in a new issue