Top level $if now uses $if: / $endif; Fix of boolean globals. Fix of $else: clause. Fix of $assert inside of $if

This commit is contained in:
Christoffer Lerno
2021-06-24 17:59:29 +02:00
committed by Christoffer Lerno
parent 321ee81c9d
commit 9572c4afc9
21 changed files with 254 additions and 139 deletions

View File

@@ -0,0 +1,65 @@
$if (0):
$else:
$if (0):
$elif (0):
$elif (0):
$else:
int x = 1;
$endif;
$endif;
$if (0):
$assert(false);
$elif (0):
$assert(false);
$else:
$assert(true);
$endif;
$if (1):
$assert(true);
int d = 5;
$elif (0):
$assert(false);
$else:
$assert(false);
$endif;
$if (0):
$assert(true);
$elif (1):
$assert(true);
int c = 5;
$else:
$assert(false);
$endif;
$if (0):
$assert(true);
$elif (1):
$assert(true);
int b = 4;
$elif (0):
$assert(false);
$else:
$assert(false);
$endif;
$if (0):
$assert(true);
$elif (0):
$assert(false);
$elif (1):
$assert(true);
int a = 3;
$else:
$assert(false);
$endif;
// #expect: ct_if.ll
@ct_if.d = global i32 5, align 4
@ct_if.c = global i32 5, align 4
@ct_if.b = global i32 4, align 4
@ct_if.a = global i32 3, align 4
@ct_if.x = global i32 1, align 4

View File

@@ -0,0 +1,31 @@
$if 3: // #error: Expected '('
$endif;
int x;
$if (x > 0):
$endif;
$if (0):
$assert(false);
$endif;
$if (1):
$else:
$endif;
$if (1):
$else:
$else: // #error: Expected a top level declaration here.
$endif;
$if (1):
$elif (2):
$else:
$endif;
$if (1):
$elif (2):
$elif (3):
$else:
$endif;