]> git.lizzy.rs Git - uwu-lang.git/blobdiff - src/parse.c
Update capitalization of Turing in the README (#1)
[uwu-lang.git] / src / parse.c
index c8b430d4963f52698b6f38caa62c77d6c3d48c11..bb9bf81f97123b226908ebe9342caf2badef85ae 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
-#include "err.h"
+#include "common/err.h"
 #include "parse.h"
 
 #define DEBUG 0
@@ -156,7 +156,7 @@ static bool parse_expression_finish(ParseState *state, char c)
        char *buffer_read = buffer_terminate(state);
 
        if (state->expression->type == EX_INTLIT || state->expression->type == EX_ARGNUM) {
-               state->expression->value.int_value = atoi(buffer_read);
+               state->expression->value.int_value = atol(buffer_read);
                free(buffer_read);
        } else {
                state->expression->value.str_value = buffer_read;
@@ -224,7 +224,7 @@ static bool parse_function(ParseState *state, char c)
        printf("%s\n", __FUNCTION__);
 #endif
 
-       if (c == '\"' || c == '$' || c == ':' || c == ',' || c == '&' || c == '(' || c == ')' || isdigit(c))
+       if (c == '\"' || c == '$' || c == '.' || c == ',' || c == '&' || c == '(' || c == ')' || isdigit(c))
                return false;
 
        if (! isspace(c)) {
@@ -285,7 +285,7 @@ AbstractSyntaxTree parse_file(const char *filename)
        FILE *f = fopen(filename, "r");
 
        if (! f)
-               error("%s: unable to open\n", filename);
+               syserror("fopen", f);
 
 #if DEBUG
        printf("[File %s]\n[Line %d]\n", filename, lines);
@@ -298,7 +298,7 @@ AbstractSyntaxTree parse_file(const char *filename)
                        break;
 
                if (ferror(f))
-                       error("%s: I/O error\n", filename);
+                       syserror("getc", f);
 
                if (c == '\n')
                        ++lines;
@@ -309,11 +309,11 @@ AbstractSyntaxTree parse_file(const char *filename)
 #endif
 
                if (! parse_character(&state, c))
-                       error("%s: syntax error in line %d\n", filename, lines);
+                       error("syntax error: in file %s, line %d\n", filename, lines);
        }
 
        if (state.buffer || state.expression)
-               error("%s: syntax error at end of file\n", filename);
+               error("syntax error: at end of file %s\n", filename);
 
        fclose(f);