28 lines
1.4 KiB
Plaintext
28 lines
1.4 KiB
Plaintext
Program {
|
|
statements = [
|
|
Comment "Here is a brief sample of the\nlanguage and its syntax",
|
|
Comment "Import statements",
|
|
Import ["std", "collections"] ["Heap", "HashMap"],
|
|
Comment "Function declaration with types",
|
|
Function (IdentifierWithType "fizz-buzz" (Just "Str")) [IdentifierWithType "i" (Just "Num")] [
|
|
Comment "This is technically a legal comment",
|
|
Let (IdentifierWithType "fb" Nothing) (LiteralString ""),
|
|
Conditional (BinaryOperation Equal (BinaryOperation Modulus (Variable "i") (LiteralInt 3)) (LiteralInt 0)) [
|
|
Assignment "fb" (BinaryOperation Concat (Variable "fb") (LiteralString "fizz"))
|
|
] Nothing,
|
|
Conditional (BinaryOperation Equal (BinaryOperation Modulus (Variable "i") (LiteralInt 5)) (LiteralInt 0)) [
|
|
Assignment "fb" (BinaryOperation Concat (Variable "fb") (LiteralString "buzz"))
|
|
] Nothing,
|
|
Conditional (FunctionCall "is-empty" [Variable "fb"]) [
|
|
Return (Variable "i")
|
|
] (Just [
|
|
Return (Variable "fb")
|
|
])
|
|
],
|
|
Comment "Function declaration without types",
|
|
Function (IdentifierWithType "main" Nothing) [] [
|
|
Const (IdentifierWithType "fb" (Just "Str")) (FunctionCall "fizz-buzz" []),
|
|
Expr (FunctionCall "print" [Variable "fb"])
|
|
]
|
|
]
|
|
} |