Moved test file + parsed file to docs/samples

This commit is contained in:
2024-03-04 02:31:58 -06:00
parent f866b602ad
commit fa245c1056
2 changed files with 28 additions and 0 deletions

28
docs/samples/test.vi.ast Normal file
View File

@@ -0,0 +1,28 @@
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"])
]
]
}