diff --git a/.gitignore b/.gitignore index 5a80a35..c5ad46e 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ modules.order Module.symvers Mkfile.old dkms.conf +vcpkg_installed/ bin diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 07c08df..0bb661b 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -2,14 +2,14 @@ "configurations": [ { "name": "Linux", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [], "compilerPath": "/usr/bin/clang", "cStandard": "c17", "cppStandard": "c++17", - "intelliSenseMode": "linux-clang-x64" + "intelliSenseMode": "linux-clang-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [] } ], "version": 4 diff --git a/src/lexer/lex.l b/src/lexer/lex.l index 830faef..597bb71 100644 --- a/src/lexer/lex.l +++ b/src/lexer/lex.l @@ -14,21 +14,9 @@ int yywrap(void *) { %% -\"((\\([\"\\\/bfnrt]|u[0-9a-fA-F]{4}))|[^\\\"\n])*\" { - return TOKEN_STRING; -} - -\'((\\([\'\\\/bfnrt]|u[0-9a-fA-F]{4}))|[^\\\'\n])*\' { - return TOKEN_STRING; -} - -((([0-9]+(\.[0-9]+)?)|(\.[0-9]+))(e((\-|\+)?([0-9]+(\.[0-9]+)?)))?) { - return TOKEN_NUMBER; -} - -([0-9]+\/[0-9]+) { - return TOKEN_FRACTION; -} +"." { return TOKEN_DOT; } +"," {return TOKEN_COMMA; } +":" {return TOKEN_COLON; } "not"[ \t]+"in" { return TOKEN_NOT_IN; } "&&" { return TOKEN_AND; } @@ -79,9 +67,21 @@ int yywrap(void *) { [a-zA-Z_][a-zA-Z0-9_]* { return TOKEN_IDENTIFIER; } -"." { return TOKEN_DOT; } -"," {return TOKEN_COMMA; } -":" {return TOKEN_COLON; } +\"((\\([\"\\\/bfnrt]|u[0-9a-fA-F]{4}))|[^\\\"\n])*\" { + return TOKEN_STRING; +} + +\'((\\([\'\\\/bfnrt]|u[0-9a-fA-F]{4}))|[^\\\'\n])*\' { + return TOKEN_STRING; +} + +((([0-9]+(\.[0-9]+)?)|(\.[0-9]+))(e((\-|\+)?([0-9]+(\.[0-9]+)?)))?) { + return TOKEN_NUMBER; +} + +([0-9]+\/[0-9]+) { + return TOKEN_FRACTION; +} \n { return TOKEN_NEW_LINE; } @@ -95,7 +95,7 @@ int yywrap(void *) { . { GET_STATE - fprintf(stderr, "%s:%u:%u: unexpected character '%s'\n", state->path, yylineno+1, COLUMN_NO+1, yytext); + fprintf(stderr, "%s:%u:%u error: unexpected character '%s'\n", state->path, yylineno, COLUMN_NO+1, yytext); exit(1); } %% \ No newline at end of file diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c index 8ecfbc9..0161805 100644 --- a/src/lexer/lexer.c +++ b/src/lexer/lexer.c @@ -15,7 +15,7 @@ void lexer(LexerState state) { Token * token_struct = create_token( token, yyget_lineno(scanner), - state.current_column, + state.current_column+1, yyget_text(scanner) ); darray_push(state.tokens, token_struct); diff --git a/src/main.c b/src/main.c index 25de7ae..9ab1aa9 100644 --- a/src/main.c +++ b/src/main.c @@ -7,9 +7,9 @@ #include #include #include -#include int main() { + ar_memory_init(); const char * path = "test.ar"; DArray tokens; @@ -33,7 +33,5 @@ int main() { darray_free(&parsed,free_parsed_value); - ar_memory_init(); - return 0; } diff --git a/src/parser/parser.c b/src/parser/parser.c index 09576cf..6f58a12 100644 --- a/src/parser/parser.c +++ b/src/parser/parser.c @@ -16,8 +16,11 @@ ParsedValue *parse_token(DArray *tokens, size_t *index) { case TOKEN_NEW_LINE: (*index)++; return NULL; + case TOKEN_INDENT: + fprintf(stderr, "error: \n"); + exit(EXIT_FAILURE); default: - fprintf(stderr, "Panic: %s\n", "unreachable"); + fprintf(stderr, "Panic: unreachable\n"); exit(EXIT_FAILURE); } } @@ -40,6 +43,5 @@ void free_parsed_value(void *ptr) { case AST_STRING: free(tagged->data); break; - // Add cases if needed } } \ No newline at end of file diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000..64cb64a --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,14 @@ +{ + "default-registry": { + "kind": "git", + "baseline": "a9eee3b18df395dbb8be71a31bd78ea441056e42", + "repository": "https://github.com/microsoft/vcpkg" + }, + "registries": [ + { + "kind": "artifact", + "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", + "name": "microsoft" + } + ] +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..4d877d3 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,6 @@ +{ + "dependencies": [ + "bdwgc", + "json-c" + ] +}