summaryrefslogtreecommitdiff
path: root/examples/if.pipa
diff options
context:
space:
mode:
authorCarlos Maniero <carlos@maniero.me>2023-05-09 16:18:18 -0300
committerJohnny Richard <johnny@johnnyrichard.com>2023-05-09 22:54:46 +0200
commitad54ee1182b1549880eddc8b1969d3992d9f7f1d (patch)
tree34d6a33a6a5ccba3ff6198d0e49f1e1d4701fc27 /examples/if.pipa
parent8c8fc8cc30b38ef00d606a4991b655df97a52fb6 (diff)
parser: parses an if statement no code generation
This commit parses a if statement following the grammar bellow: if boolean_expression { n_epressions; } No else neither code generation was implemented. Signed-off-by: Carlos Maniero <carlos@maniero.me>
Diffstat (limited to 'examples/if.pipa')
-rw-r--r--examples/if.pipa9
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/if.pipa b/examples/if.pipa
new file mode 100644
index 0000000..2c5578d
--- /dev/null
+++ b/examples/if.pipa
@@ -0,0 +1,9 @@
+fn main(): i32 {
+ let n: i32 = 42;
+
+ if n > 42 {
+ return 42;
+ }
+
+ return n;
+}