summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorCarlos Maniero <carlos@maniero.me>2023-05-03 23:17:50 -0300
committerJohnny Richard <johnny@johnnyrichard.com>2023-05-04 21:47:51 +0200
commite2e0ed950bb147ebca3b9ac879268feeb185e20b (patch)
treed6888d4468d75a9d4498f20976b66a3d4bd8575a /examples
parent8655b77d57ace45d4d040ef297cf172f3c12f4bd (diff)
parser: Introduce statement keywords
This commit introduces a few changes in pipalang syntax. Now, both functions and variables requires keywords to be defined. before: main(): i32 { a: i32 = 2; return a; } now: fn main(): i32 { let a: i32 = 2; return a; } Signed-off-by: Carlos Maniero <carlos@maniero.me> Reviewed-by: Johnny Richard <johnny@johnnyrichard.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/arithmetics.pipa2
-rw-r--r--examples/main.pipa2
-rw-r--r--examples/variables.pipa12
3 files changed, 8 insertions, 8 deletions
diff --git a/examples/arithmetics.pipa b/examples/arithmetics.pipa
index e2b7645..f2449b8 100644
--- a/examples/arithmetics.pipa
+++ b/examples/arithmetics.pipa
@@ -1,3 +1,3 @@
-main(): i32 {
+fn main(): i32 {
return ((2 + 1) * (5 - 3) + 7) * 2 / 2;
}
diff --git a/examples/main.pipa b/examples/main.pipa
index 6524bec..2da2231 100644
--- a/examples/main.pipa
+++ b/examples/main.pipa
@@ -1,3 +1,3 @@
-main(): i32 {
+fn main(): i32 {
return 69;
}
diff --git a/examples/variables.pipa b/examples/variables.pipa
index 0723782..3eabc73 100644
--- a/examples/variables.pipa
+++ b/examples/variables.pipa
@@ -1,10 +1,10 @@
-main(): i32 {
- a: i32 = 13;
+fn main(): i32 {
+ let a: i32 = 13;
a = a - 1;
- b: i32 = 33;
+ let b: i32 = 33;
b = 32;
- c: i32 = 2 * (b + a);
- d: i32 = (c - 33) + 1;
- e: i32 = d;
+ let c: i32 = 2 * (b + a);
+ let d: i32 = (c - 33) + 1;
+ let e: i32 = d;
return e / 2;
}