aboutsummaryrefslogtreecommitdiff
path: root/Sil/Syntax.dcl
diff options
context:
space:
mode:
Diffstat (limited to 'Sil/Syntax.dcl')
-rw-r--r--Sil/Syntax.dcl52
1 files changed, 52 insertions, 0 deletions
diff --git a/Sil/Syntax.dcl b/Sil/Syntax.dcl
new file mode 100644
index 0000000..01b7ff6
--- /dev/null
+++ b/Sil/Syntax.dcl
@@ -0,0 +1,52 @@
+definition module Sil.Syntax
+
+from Data.Maybe import :: Maybe
+
+:: Program =
+ { p_funs :: [Function]
+ }
+
+:: Function =
+ { f_type :: Type
+ , f_name :: Name
+ , f_args :: [Arg]
+ , f_code :: CodeBlock
+ }
+
+:: CodeBlock =
+ { cb_init :: [Initialisation]
+ , cb_content :: [Statement]
+ }
+
+:: Arg =
+ { arg_type :: Type
+ , arg_name :: Name
+ }
+
+:: Initialisation =
+ { init_type :: Type
+ , init_name :: Name
+ }
+
+:: Statement
+ = Declaration Name Application
+ | Application Application
+ | Return (Maybe Application)
+ | If Application CodeBlock (Maybe CodeBlock)
+ | While Application CodeBlock
+
+:: Application
+ = Name Name
+ | Literal Literal
+ | App Name [Application]
+
+:: Type
+ = TBool
+ | TInt
+ | TVoid
+
+:: Literal
+ = BLit Bool
+ | ILit Int
+
+:: Name :== String