mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fixed a lot of while/if/for. ?: now works.
This commit is contained in:
@@ -197,26 +197,11 @@ macro_argument_list
|
||||
| macro_argument_list ',' macro_argument
|
||||
;
|
||||
|
||||
implicit_decl
|
||||
: IDENT
|
||||
| IDENT '=' initializer
|
||||
;
|
||||
|
||||
explicit_decl
|
||||
declaration
|
||||
: type_expression IDENT '=' initializer
|
||||
| type_expression IDENT
|
||||
;
|
||||
|
||||
declaration
|
||||
: explicit_decl
|
||||
| explicit_decl ',' implicit_decl
|
||||
| explicit_decl ',' explicit_decl
|
||||
;
|
||||
|
||||
declaration_list
|
||||
: declaration
|
||||
;
|
||||
|
||||
param_declaration
|
||||
: type_expression
|
||||
| type_expression IDENT
|
||||
@@ -391,8 +376,8 @@ expression_statement
|
||||
|
||||
|
||||
control_expression
|
||||
: decl_or_expr_list
|
||||
| declaration_list ';' decl_or_expr_list
|
||||
: decl_expr_list
|
||||
| decl_expr_list ';' decl_expr_list
|
||||
;
|
||||
|
||||
selection_statement
|
||||
@@ -406,14 +391,16 @@ expression_list
|
||||
| expression_list ',' expression
|
||||
;
|
||||
|
||||
decl_or_expr_list
|
||||
: expression_list
|
||||
| declaration_list
|
||||
decl_expr_list
|
||||
: expression
|
||||
| declaration
|
||||
| decl_expr_list ',' expression
|
||||
| decl_expr_list ',' declaration
|
||||
;
|
||||
|
||||
for_statement
|
||||
: FOR '(' decl_or_expr_list ';' expression_statement ')' statement
|
||||
| FOR '(' decl_or_expr_list ';' expression_statement expression_list ')' statement
|
||||
: FOR '(' decl_expr_list ';' expression_statement ')' statement
|
||||
| FOR '(' decl_expr_list ';' expression_statement expression_list ')' statement
|
||||
;
|
||||
|
||||
iteration_statement
|
||||
|
||||
@@ -23,6 +23,20 @@ union Test3
|
||||
|
||||
func int boba(int y, int j)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
|
||||
}
|
||||
for (int i = 0, int foo = 0; i < 10; i++)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0, j = 1; i < 10; i++, j++)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Test2 bar;
|
||||
bar.b = 1;
|
||||
//int w = y ? y : j;
|
||||
@@ -66,6 +80,11 @@ func int test(int x)
|
||||
return y;
|
||||
}
|
||||
|
||||
func int* elvis(int *x, int *y)
|
||||
{
|
||||
return x ?: y;
|
||||
}
|
||||
|
||||
func int test3()
|
||||
{
|
||||
if (test() < 0) return -1;
|
||||
@@ -93,6 +112,26 @@ func void bob()
|
||||
|
||||
func int main(int x)
|
||||
{
|
||||
for (int ok = 0; ok < 10; ok++)
|
||||
{
|
||||
printf("ok");
|
||||
}
|
||||
printf("\n");
|
||||
for (int ok = 0, int ko = 0, ok = 2; ok + ko < 10; ok++, ko++)
|
||||
{
|
||||
printf(":okko");
|
||||
}
|
||||
printf("\n");
|
||||
while (int ok = 0; int j = ok++, ok < 10)
|
||||
{
|
||||
printf("foo");
|
||||
}
|
||||
printf("\n");
|
||||
x = 3;
|
||||
if (int odk = x, x > 0)
|
||||
{
|
||||
printf("helo\n");
|
||||
}
|
||||
Test2 efe;
|
||||
efe.t.a = 3;
|
||||
if (efe.t.a > 2) printf("Works!\n");
|
||||
|
||||
Reference in New Issue
Block a user