summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--identifiers.c5
-rw-r--r--main.c27
-rw-r--r--test.toc6
-rw-r--r--types.c3
4 files changed, 25 insertions, 16 deletions
diff --git a/identifiers.c b/identifiers.c
index 522180d..b407e39 100644
--- a/identifiers.c
+++ b/identifiers.c
@@ -99,6 +99,11 @@ static void fprint_ident(FILE *out, Identifier id) {
fputc(c, out);
}
+static void print_ident(Identifier id) {
+ fprint_ident(stdout, id);
+ printf("\n");
+}
+
/* reduced charset = a-z, A-Z, 0-9, _ */
static void fprint_ident_reduced_charset(FILE *out, Identifier id) {
assert(id);
diff --git a/main.c b/main.c
index 592dc7d..43f3927 100644
--- a/main.c
+++ b/main.c
@@ -19,6 +19,9 @@
/*
TODO:
+params with default values before params without them
+check for duplicate params
+inferred const params
packages
X ::= newtype(int); or something
don't allow while {3; 5} (once break is added)
@@ -98,13 +101,16 @@ int main(int argc, char **argv) {
err_fprint(TEXT_IMPORTANT("Errors occured while preprocessing.\n"));
return EXIT_FAILURE;
}
+
+#if 0
+ arr_foreach(t.tokens, Token, token) {
+ if (token != t.tokens)
+ printf(" ");
+ fprint_token(stdout, token);
+ }
+ printf("\n");
+#endif
- /* arr_foreach(t.tokens, Token, token) { */
- /* if (token != t.tokens) */
- /* printf(" "); */
- /* fprint_token(stdout, token); */
- /* } */
- /* printf("\n"); */
Parser p;
parser_create(&p, &t, &main_allocr);
ParsedFile f;
@@ -113,9 +119,10 @@ int main(int argc, char **argv) {
err_fprint(TEXT_IMPORTANT("Errors occured while parsing.\n"));
return EXIT_FAILURE;
}
- /* fprint_parsed_file(stdout, &f); */
-
- /* printf("\n\n-----\n\n"); */
+#if 0
+ fprint_parsed_file(stdout, &f);
+ printf("\n\n-----\n\n");
+#endif
tokr_free(&t);
@@ -127,7 +134,6 @@ int main(int argc, char **argv) {
if (!block_enter(NULL, f.stmts, SCOPE_CHECK_REDECL)) /* enter global scope */
return false;
- /* fprint_parsed_file(stdout, &f); */
if (!types_file(&tr, &f)) {
err_fprint(TEXT_IMPORTANT("Errors occured while determining types.\n"));
return EXIT_FAILURE;
@@ -155,7 +161,6 @@ int main(int argc, char **argv) {
evalr_free(&ev);
fclose(out);
- /* fclose(h_out); */
idents_free(&file_idents);
}
diff --git a/test.toc b/test.toc
index 3ea56d1..502f2cb 100644
--- a/test.toc
+++ b/test.toc
@@ -1,7 +1,7 @@
-f ::= fn(y:f64=19.2) {
-
+f ::= fn(y:f64=19.2, x : f64) f64 {
+ x + y
};
main ::= fn() {
- f(13);
+ f(x = 13, y = 3);
};
diff --git a/types.c b/types.c
index a65d8d6..f4e06ce 100644
--- a/types.c
+++ b/types.c
@@ -1073,14 +1073,13 @@ static bool types_expr(Typer *tr, Expression *e) {
bool found = false;
arr_foreach(fn_decl->params, Declaration, pa) {
arr_foreach(pa->idents, Identifier, id) {
- if (*id == args[index].name) {
+ if (*id == arg->name) {
found = true;
break;
}
index++;
}
if (found) break;
- index++;
}
if (!found) {
char *s = ident_to_str(arg->name);