2022-02-09 00:26:58 +00:00
|
|
|
module Luau.Syntax where
|
|
|
|
|
2022-02-12 01:03:26 +00:00
|
|
|
open import Agda.Builtin.Equality using (_≡_)
|
2022-02-18 19:09:00 +00:00
|
|
|
open import Agda.Builtin.Float using (Float)
|
2022-02-12 01:03:26 +00:00
|
|
|
open import Properties.Dec using (⊥)
|
2022-02-09 23:14:29 +00:00
|
|
|
open import Luau.Var using (Var)
|
|
|
|
open import Luau.Addr using (Addr)
|
2022-02-12 01:03:26 +00:00
|
|
|
open import Luau.Type using (Type)
|
2022-02-09 00:26:58 +00:00
|
|
|
|
|
|
|
infixr 5 _∙_
|
|
|
|
|
2022-02-12 01:03:26 +00:00
|
|
|
data Annotated : Set where
|
|
|
|
maybe : Annotated
|
|
|
|
yes : Annotated
|
|
|
|
|
|
|
|
data VarDec : Annotated → Set where
|
|
|
|
var : Var → VarDec maybe
|
|
|
|
var_∈_ : ∀ {a} → Var → Type → VarDec a
|
|
|
|
|
|
|
|
name : ∀ {a} → VarDec a → Var
|
|
|
|
name (var x) = x
|
|
|
|
name (var x ∈ T) = x
|
|
|
|
|
|
|
|
data FunDec : Annotated → Set where
|
|
|
|
_⟨_⟩∈_ : ∀ {a} → Var → VarDec a → Type → FunDec a
|
|
|
|
_⟨_⟩ : Var → VarDec maybe → FunDec maybe
|
|
|
|
|
|
|
|
fun : ∀ {a} → FunDec a → Var
|
|
|
|
fun (f ⟨ x ⟩∈ T) = f
|
|
|
|
fun (f ⟨ x ⟩) = f
|
|
|
|
|
|
|
|
arg : ∀ {a} → FunDec a → VarDec a
|
|
|
|
arg (f ⟨ x ⟩∈ T) = x
|
|
|
|
arg (f ⟨ x ⟩) = x
|
|
|
|
|
|
|
|
data Block (a : Annotated) : Set
|
|
|
|
data Stat (a : Annotated) : Set
|
|
|
|
data Expr (a : Annotated) : Set
|
|
|
|
|
|
|
|
data Block a where
|
|
|
|
_∙_ : Stat a → Block a → Block a
|
|
|
|
done : Block a
|
|
|
|
|
|
|
|
data Stat a where
|
|
|
|
function_is_end : FunDec a → Block a → Stat a
|
|
|
|
local_←_ : VarDec a → Expr a → Stat a
|
|
|
|
return : Expr a → Stat a
|
|
|
|
|
|
|
|
data Expr a where
|
|
|
|
nil : Expr a
|
|
|
|
var : Var → Expr a
|
|
|
|
addr : Addr → Expr a
|
|
|
|
_$_ : Expr a → Expr a → Expr a
|
|
|
|
function_is_end : FunDec a → Block a → Expr a
|
|
|
|
block_is_end : Var → Block a → Expr a
|
2022-02-18 19:09:00 +00:00
|
|
|
number : Float → Expr a
|