From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 2A3FBFVoAGckQQEAe85BDQ:P1 (envelope-from ) for ; Sat, 05 Oct 2024 00:12:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 2A3FBFVoAGckQQEAe85BDQ (envelope-from ) for ; Sat, 05 Oct 2024 00:12:37 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=j73X+PSU; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=qCxXLvjU; dmarc=pass (policy=none) header.from=maniero.me; arc=pass ("mailchannels.net:s=arc-2022:i=1"); spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht ARC-Seal: i=2; s=key1; d=johnnyrichard.com; t=1728079956; a=rsa-sha256; cv=pass; b=cAOzpU/s9fER+2Xie2o8fpzj8fJpVbMbYtpQ95gODdRdeQt22TWf+Gc4E7e0CyUoWbB8Gd 0HMbKMmB5jq9qoMS4tCIBOA1oGbryqq7sA/cFDzLisEhoINRZ7KFdC1Z2EnY1iVr5MxSU/ NEpsDtJ1/MNgmA/m2tLYisHt+dXvAhLHc6gDM3+32q55bZT4ZjYrUXxR4XKtLRPAHPyZPh Dn3GgW9cUhJL4YWhhMtiVa8wSjPPMXmNk1OKPeUTWBLYWrWDuGV9ecHsafYeocPP9AsyAr koZbt15/IcPc6QFCn4fSiHpYXyaArhAHSF0ub2Ekc4/XhURoraL4cPWB61NAUw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=j73X+PSU; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=qCxXLvjU; dmarc=pass (policy=none) header.from=maniero.me; arc=pass ("mailchannels.net:s=arc-2022:i=1"); spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1728079956; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=HsTabTk89fi1fd15xmAq0Fy/KAEUflv6NdOeuk4j7sc=; b=etMdP6rJXsn36RuHGlnF32jLfBstFq/soA9X+GnNCej5BGK6UHUuPzFSTK+k7nTZkJbTpM IAArUJKt/xJSt2DIRyBFzbnoiBvd9l+tWMugwLkbMfRNrwX/6AEYGoPLImOuEzRVgYVvUG mdrriLp7KYWkFo/Wzl/L/2haCux/kpdgmKoEgaEGQQAfWk2svb0CFLJ1NMo+J9argdTiQX nL+v0JVNibCCzhSxwrljhIr/vrE7Hmu0LsgjP5KsNK1XzhiB1mkVWcOnDWW1WRWOL+8pBV iZdaC5xx7mxJYAWq6Fl95wyau0v/FygUrnYOAMOLgfT4RwwYOqHWfjMvEAGp0w== Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 964D287FCE for ; Sat, 05 Oct 2024 00:12:36 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=81Rpfv1t36Nfe7LU6xiHMhOjxeCYRu1FoYFBlRHjJ18=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:Date:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1728079949; v=1; b=j73X+PSUBT8ljUe2vht3j+5WUN7c0UNoAOtmFYrM5VHSf42R5uzXttiklWRxP3yc/PhXgTRa m7x2YGrkfHjtQ3q3rjpjnRg1nbgmpHwqupjgnD9iwd57AuZNxsafD02ouDq3TFd700W5d3JPCF3 Oi1FoFHFdyobTcETcupukFGBHGG2dT4SRcX6KwLWg/vDbcRojjXL/4IXGUOFS9XkJFFvQwha30E alluWDkA8CYh4GITDzDtXOS/ET1AMkPXJOIKIUPljri/J1wTwt9yShltOP8JsfbT66hT+93eU/W gcw0Xp3jXOoGDRgtGoKiNnoRRw2KObzMNTpGijPLnEpzw== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id 219A220243 for ; Fri, 04 Oct 2024 22:12:29 +0000 (UTC) Received: from seagreen.cherry.relay.mailchannels.net (seagreen.cherry.relay.mailchannels.net [23.83.223.160]) by mail-a.sr.ht (Postfix) with ESMTPS id E42BD20233 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 04 Oct 2024 22:12:23 +0000 (UTC) X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 04A4721479 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 4 Oct 2024 22:12:22 +0000 (UTC) Received: from uk-fast-smtpout10.hostinger.io (100-101-192-86.trex-nlb.outbound.svc.cluster.local [100.101.192.86]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 3015B21E87 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 4 Oct 2024 22:12:21 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1728079941; a=rsa-sha256; cv=none; b=Fvti4XZO0NZICffKNZKA7uvNy9SFat1BAYHXItd20cjoHy/TiD+ugucXWck2ZE9Fpq1Xjq gw0czs3Nj4YCtCIMBj+ezDNnJ41fPPrJ+qGVnqrdfr3st2Cv4SFBsh0joMv/W6xRQDKJhM lyijkptSQ7DvdenG1zFKUuMSFt1jYBn12KjEHnT5Dpg5lJaRjPMRPsojn9nTgLt8GBYZUF VM0FDKkDJxfrDjIdv5PC7PoR9Dsfl3eVLAlucMNOa4VOJRMoxX3OOAG4CWVX5jp0EANakR T8m0kgrKNM6ANy4KFeHx4P+w1/41aSQ23ssfTAvs3VewzgiIS6nm4xWg3hcCEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1728079941; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=HsTabTk89fi1fd15xmAq0Fy/KAEUflv6NdOeuk4j7sc=; b=CTn+sado/SaOUDiVn52XER84HyaHAdLPzZOfsPhDjdq9jDfUc9Dt8U5lSCaiL7m9BZ/W1S micbfVZPO9rKxUnzFZ9H7QiN6P+1rmHx2AI7oOW6Xw+JwleRopqjCGDwhhvaJitpnQBZW3 qveXg2pmg98rQT8ck/hTXzpEbvfxnCbp8sk59OvyMN8WKWluKFk3qFJPagOkYRi7wxJttu sl25pkciYg3KRKIAKrYIMht26IxtvrfxQtqokDMqsZUzEaVyd0IxlajEtOngm1Hbp1whgh 4UrX1X5YAiNdnH+ZF1LscT8I0zc0VEC0npVAq+Z3rE46elwfrZWLekK2pRxM6A== ARC-Authentication-Results: i=1; rspamd-58b99b864b-s5hvx; auth=pass smtp.auth=hostingeremail smtp.mailfrom=carlos@maniero.me X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me X-MC-Relay: Neutral X-MailChannels-SenderId: hostingeremail|x-authuser|carlos@maniero.me X-MailChannels-Auth-Id: hostingeremail X-Hysterical-Tank: 75215b4978e5d197_1728079941756_1113239480 X-MC-Loop-Signature: 1728079941756:3631501096 X-MC-Ingress-Time: 1728079941755 Received: from uk-fast-smtpout10.hostinger.io (uk-fast-smtpout10.hostinger.io [145.14.155.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.101.192.86 (trex/7.0.2); Fri, 04 Oct 2024 22:12:21 +0000 From: Carlos Maniero DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1728079939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=HsTabTk89fi1fd15xmAq0Fy/KAEUflv6NdOeuk4j7sc=; b=qCxXLvjURFdOAJXwIhWXPoMyKhBBj3VdHlWG03iFyYIBmbSCbOyEHvW4zuvVYGTPl4q04T ozJKjlhJqzmIf/cjQzy2j3cPBbqpwEZz+g7MdJJXctPDA+ygklRoFNE2HJcos8IGqdbide ruZKB7gmCpO79v9EFMTaxCGZcDPlC0Ik8XHbZ25Ht8tntMRU4n5ol8LMcrtbTSw3VMAPp2 U6kJINllrxucVdXpTAzY1dXa7ozVaZRhJuWsFgUqcA6G4gKqfUzcTQQc/evNLcUXsYGDBL VHZAuMHEbhY0/4EiPubaM74PFP3iUgOCrrKTeWzO2+5iZqhrlyVLMjoJ0zXc3A== To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Carlos Maniero Subject: [PATCH olang] lexer: create token location structure Message-Id: <20241004221157.153364-1-carlos@maniero.me> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Fri, 04 Oct 2024 22:12:18 +0000 (UTC) X-CM-Analysis: v=2.4 cv=TcnEtgQh c=1 sm=1 tr=0 ts=67006843 a=WwxFCuf3mf1fs3oSi6/dng==:117 a=WwxFCuf3mf1fs3oSi6/dng==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=mDV3o1hIAAAA:8 a=fgtbUIOpPKFuhrw2CzsA:9 a=BXDaF_L80NY05PYiAFlV:22 X-CM-Envelope: MS4xfC/mhghLlAJ9nreAmYUwfa8NdDU88UEnOFK66liaoIeGYC9BvnLPgsvnpDP6BaohtNblPgTn477Najz60eiCDKtTdueTFB/dzfQrJDoI4nTHzkNfj3WH nN+b5uwlqjSRJD6sNe+KiIuo1EUaylRa31EKBcRn8l3lQ33ht6G5f66WEMTV+xkf0mHkBQWjMl1TdpfAg1xBHbIVxrVIEe32C8YzbWjt7K/OydpLCGZERpoP X-AuthUser: carlos@maniero.me X-Sourcehut-Patchset-Status: PROPOSED List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Country: NL X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -5.75 X-Spam-Score: -5.75 X-Migadu-Queue-Id: 964D287FCE X-Migadu-Scanner: mx10.migadu.com X-TUID: iAAu+2j+ZcF/ To reach the source line and column to print errors, we use to get the filepath from parser, the cursor from token and the source code from the lexer. Now, instead of navigating into these three data structures, the same information must be accessible from a single place, the token's location *token_loc_t*. The source_code.h file was removed once the source code struct was added to the lexer. Signed-off-by: Carlos Maniero --- src/lexer.c | 26 +++++++++++++++++++------- src/lexer.h | 23 ++++++++++++++++++++--- src/main.c | 18 +++++++++--------- src/parser.c | 33 +++++++++++++++------------------ src/parser.h | 4 +--- src/source_code.h | 28 ---------------------------- tests/unit/parser_test.c | 2 +- 7 files changed, 65 insertions(+), 69 deletions(-) delete mode 100644 src/source_code.h diff --git a/src/lexer.c b/src/lexer.c index 523822f..4784f1c 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -396,21 +396,21 @@ static void lexer_init_char_value_token(lexer_t *lexer, token_t *token, token_kind_t kind) { string_view_t str = { .chars = lexer->src.code.chars + lexer->cur.offset, .size = 1 }; - *token = (token_t){ .kind = kind, .value = str, .cur = lexer->cur }; + *token = (token_t){ .kind = kind, .value = str, .loc = (token_loc_t){ .src = lexer->src, .cur = lexer->cur } }; } static void lexer_init_str_value_token(lexer_t *lexer, token_t *token, token_kind_t kind, lexer_cursor_t cur) { string_view_t str = { .chars = lexer->src.code.chars + cur.offset, .size = lexer->cur.offset - cur.offset }; - *token = (token_t){ .kind = kind, .value = str, .cur = cur }; + *token = (token_t){ .kind = kind, .value = str, .loc = (token_loc_t){ .src = lexer->src, .cur = cur } }; } static void lexer_init_eof_token(lexer_t *lexer, token_t *token) { string_view_t str = { 0 }; - *token = (token_t){ .kind = TOKEN_EOF, .value = str, .cur = lexer->cur }; + *token = (token_t){ .kind = TOKEN_EOF, .value = str, .loc = (token_loc_t){ .src = lexer->src, .cur = lexer->cur } }; } static token_kind_t @@ -458,14 +458,26 @@ lexer_lookahead(lexer_t *lexer, token_t *token, size_t n) } string_view_t -lexer_get_token_line(lexer_t *lexer, token_t *token) +token_loc_to_line(token_loc_t loc) { - size_t offset = token->cur.bol; - string_view_t line = { .chars = lexer->src.code.chars + offset, .size = 0 }; + size_t offset = loc.cur.bol; + string_view_t line = { .chars = loc.src.code.chars + offset, .size = 0 }; - while ((line.size + offset) < lexer->src.code.size && line.chars[line.size] != '\n' && line.chars[line.size] != 0) { + while ((line.size + offset) < loc.src.code.size && line.chars[line.size] != '\n' && line.chars[line.size] != 0) { ++line.size; } return line; } + +size_t +token_loc_to_lineno(token_loc_t loc) +{ + return loc.cur.row + 1; +} + +size_t +token_loc_to_colno(token_loc_t loc) +{ + return loc.cur.offset - loc.cur.bol + 1; +} diff --git a/src/lexer.h b/src/lexer.h index c5a342a..bb39a70 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -17,11 +17,16 @@ #ifndef LEXER_H #define LEXER_H -#include "source_code.h" #include "string_view.h" #include #include +typedef struct source_code +{ + char *filepath; + string_view_t code; +} source_code_t; + typedef struct lexer_cursor { size_t offset; @@ -85,13 +90,25 @@ typedef enum token_kind TOKEN_EOF } token_kind_t; +typedef struct token_loc +{ + source_code_t src; + lexer_cursor_t cur; +} token_loc_t; + typedef struct token { token_kind_t kind; string_view_t value; - lexer_cursor_t cur; + token_loc_t loc; } token_t; +size_t +token_loc_to_lineno(token_loc_t loc); + +size_t +token_loc_to_colno(token_loc_t loc); + void lexer_init(lexer_t *lexer, source_code_t src); @@ -111,6 +128,6 @@ bool token_kind_is_binary_op(token_kind_t kind); string_view_t -lexer_get_token_line(lexer_t *lexer, token_t *token); +token_loc_to_line(token_loc_t loc); #endif /* LEXER_H */ diff --git a/src/main.c b/src/main.c index 4c8f2a5..d1c76e3 100644 --- a/src/main.c +++ b/src/main.c @@ -44,7 +44,7 @@ void handle_codegen_linux(cli_opts_t *opts); static void -print_token(char *filepath, token_t *token); +print_token(token_t *token); source_code_t read_entire_file(char *filepath, arena_t *arena); @@ -89,10 +89,10 @@ handle_dump_tokens(cli_opts_t *opts) token_t token = { 0 }; lexer_next_token(&lexer, &token); while (token.kind != TOKEN_EOF) { - print_token(opts->filepath, &token); + print_token(&token); lexer_next_token(&lexer, &token); } - print_token(opts->filepath, &token); + print_token(&token); arena_free(&arena); } @@ -112,7 +112,7 @@ handle_dump_ast(cli_opts_t *opts) source_code_t src = read_entire_file(opts->filepath, &arena); lexer_init(&lexer, src); - parser_init(&parser, &lexer, &arena, opts->filepath); + parser_init(&parser, &lexer, &arena); ast_node_t *ast = parser_parse_translation_unit(&parser); @@ -133,7 +133,7 @@ handle_codegen_linux(cli_opts_t *opts) source_code_t src = read_entire_file(opts->filepath, &arena); lexer_init(&lexer, src); - parser_init(&parser, &lexer, &arena, opts->filepath); + parser_init(&parser, &lexer, &arena); ast_node_t *ast = parser_parse_translation_unit(&parser); @@ -242,11 +242,11 @@ read_entire_file(char *filepath, arena_t *arena) } static void -print_token(char *filepath, token_t *token) +print_token(token_t *token) { printf("%s:%lu:%lu: <%s>\n", - filepath, - token->cur.row + 1, - (token->cur.offset - token->cur.bol) + 1, + token->loc.src.filepath, + token_loc_to_lineno(token->loc), + token_loc_to_colno(token->loc), token_kind_to_cstr(token->kind)); } diff --git a/src/parser.c b/src/parser.c index 26e5465..ecc10f0 100644 --- a/src/parser.c +++ b/src/parser.c @@ -32,7 +32,7 @@ static bool expected_next_token(parser_t *parser, token_t *token, token_kind_t kind); static bool -expected_token(parser_t *parser, token_t *token, token_kind_t kind); +expected_token(token_t *token, token_kind_t kind); static bool parser_parse_type(parser_t *parser, string_view_t *type); @@ -68,14 +68,12 @@ static void skip_line_feeds(lexer_t *lexer); void -parser_init(parser_t *parser, lexer_t *lexer, arena_t *arena, char *file_path) +parser_init(parser_t *parser, lexer_t *lexer, arena_t *arena) { assert(parser && "parser is required"); assert(lexer && "lexer is required"); - assert(file_path && "file_path is required"); parser->lexer = lexer; parser->arena = arena; - parser->file_path = file_path; } ast_node_t * @@ -311,7 +309,7 @@ parser_parse_fn_args(parser_t *parser) bool is_not_first_arg = false; while (token.kind != TOKEN_CPAREN && token.kind != TOKEN_EOF) { - if (is_not_first_arg && expected_token(parser, &token, TOKEN_COMMA)) { + if (is_not_first_arg && expected_token(&token, TOKEN_COMMA)) { lexer_next_token(parser->lexer, &token); } @@ -353,11 +351,11 @@ parser_parse_fn_params(parser_t *parser) bool is_not_first_param = false; while (token.kind != TOKEN_CPAREN && token.kind != TOKEN_EOF) { - if (is_not_first_param && expected_token(parser, &token, TOKEN_COMMA)) { + if (is_not_first_param && expected_token(&token, TOKEN_COMMA)) { lexer_next_token(parser->lexer, &token); } - if (!expected_token(parser, &token, TOKEN_ID)) { + if (!expected_token(&token, TOKEN_ID)) { return NULL; } @@ -372,7 +370,7 @@ parser_parse_fn_params(parser_t *parser) is_not_first_param = true; } - if (!expected_token(parser, &token, TOKEN_CPAREN)) { + if (!expected_token(&token, TOKEN_CPAREN)) { return NULL; } @@ -555,7 +553,7 @@ parser_parse_if_stmt(parser_t *parser) return NULL; } - } else if (!expected_token(parser, &next_token, TOKEN_LF)) { + } else if (!expected_token(&next_token, TOKEN_LF)) { return NULL; } @@ -613,24 +611,23 @@ static bool expected_next_token(parser_t *parser, token_t *token, token_kind_t expected_kind) { lexer_next_token(parser->lexer, token); - return expected_token(parser, token, expected_kind); + return expected_token(token, expected_kind); } static bool -expected_token(parser_t *parser, token_t *token, token_kind_t expected_kind) +expected_token(token_t *token, token_kind_t expected_kind) { if (token->kind != expected_kind) { fprintf(stderr, - "%s:%lu:%lu: error: got '" SV_FMT "' token but expect <%s>\n", - parser->file_path, - token->cur.row + 1, - (token->cur.offset - token->cur.bol) + 1, + "%s:%lu:%lu: syntax error: got '" SV_FMT "' token but expect '%s'\n", + token->loc.src.filepath, + token_loc_to_lineno(token->loc), + token_loc_to_colno(token->loc), SV_ARG(token->value), token_kind_to_cstr(expected_kind)); - string_view_t line = lexer_get_token_line(parser->lexer, token); - fprintf(stderr, "" SV_FMT "\n", SV_ARG(line)); - fprintf(stderr, "%*s\n", (int)(token->cur.offset - token->cur.bol + 1), "^"); + fprintf(stderr, SV_FMT "\n", SV_ARG(token_loc_to_line(token->loc))); + fprintf(stderr, "%*s\n", (int)token_loc_to_colno(token->loc), "^"); exit(EXIT_FAILURE); } diff --git a/src/parser.h b/src/parser.h index 31c0dc3..7db2b74 100644 --- a/src/parser.h +++ b/src/parser.h @@ -25,12 +25,10 @@ typedef struct parser { lexer_t *lexer; arena_t *arena; - // TODO: we should define a better place to file_path string - char *file_path; } parser_t; void -parser_init(parser_t *parser, lexer_t *lexer, arena_t *arena, char *file_path); +parser_init(parser_t *parser, lexer_t *lexer, arena_t *arena); ast_node_t * parser_parse_translation_unit(parser_t *parser); diff --git a/src/source_code.h b/src/source_code.h deleted file mode 100644 index 2c774c7..0000000 --- a/src/source_code.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2024 olang maintainers - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "string_view.h" - -#ifndef SOURCE_CODE_H -#define SOURCE_CODE_H - -typedef struct source_code -{ - char *filepath; - string_view_t code; -} source_code_t; - -#endif diff --git a/tests/unit/parser_test.c b/tests/unit/parser_test.c index 9eb56fd..c834261 100644 --- a/tests/unit/parser_test.c +++ b/tests/unit/parser_test.c @@ -39,7 +39,7 @@ parse_translation_unit_test(const MunitParameter params[], void *user_data_or_fi lexer_init(&lexer, (source_code_t){ .code = code, .filepath = filepath }); parser_t parser; - parser_init(&parser, &lexer, &arena, filepath); + parser_init(&parser, &lexer, &arena); ast_node_t *translation_unit_node = parser_parse_translation_unit(&parser); assert_not_null(translation_unit_node); base-commit: 83fd6730450617e85376acdec1f4bb396fff26c8 -- 2.34.1