From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id +LGSGETq8WbHLQEAe85BDQ:P1 (envelope-from ) for ; Tue, 24 Sep 2024 00:23:00 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id +LGSGETq8WbHLQEAe85BDQ (envelope-from ) for ; Tue, 24 Sep 2024 00:23:00 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; none 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 54F7767FDD for ; Tue, 24 Sep 2024 00:23:00 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=4ZOBKxHRvY9DJih75Uq8aj6/hJvznZVvxg0R4CLJQVU=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1727130179; v=1; b=Nylf5Y4PCuW+VD57SL4uYWklZ7gJ7JtO3zuupYKYuiwYWZsf+0NMYKkpHgsYibkadVXbGKFG IyGlPhhcGw3VpmdaxQsbabcFPDI1K0/jGqNcBu+eTRmvt7MuKvq2eXl+/mCovNs+VsX+sAfuGbA cNAbiFkvwANicDHVtpzVmgmLaSzI2HS0+ESvGrBHMbQ0gjkbDH6HPHyMQxWvR+1uGFsNZcnApBF l1V8w/3/Oqkm5ULuliGMhhxsd6xXBur9szMDTid136OZoIGPgVrNN/eI+pj2UkICWLXi5ve9TY9 2Iy6I6qlW5HPs9OP37CzVbV8qPnvsnDpkcpEuAAomHUUg== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id B064620223 for ; Mon, 23 Sep 2024 22:22:59 +0000 (UTC) Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) by mail-a.sr.ht (Postfix) with ESMTPS id E3159201ED for <~johnnyrichard/olang-devel@lists.sr.ht>; Mon, 23 Sep 2024 22:22:57 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1727130177; 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: in-reply-to:in-reply-to:references:references; bh=pS4Vi7o5vaDLhRNyg4qaO2TRok6+Lkoi4rcJBbR9n8s=; b=nD9bYnxazfHndx+r8HJ5eO9fCw/Pl5ayTY9/lEgUi6Qa6Cwf8NVkQQqL2MySAiBs629LM9 RxO9PQn2dqZhXoMPgQZbTmeTRTpfUi49j91aUF2TJDMLwDbztcNYqTY3qZJOoYNrRZqhau xglVJbJQ6AzNTAS+WGV5tAPDDYnqUTVXwU3cogPQClMTMIT2IYsn4xPl5mOSEFtR4A9XIy 3ePBJOnVHWsQkIsHp2Tn6PffVrFdJ+XurTkgurMlmYrOjFE4B+jXSjGWN8Jlv87fKJNchz dTVfzOF6+O5lHZSFnSGAYdiG+os/wiuM1w8XhHNilKkYiNDCwDfwnBuGIPO+MQ== From: Johnny Richard To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Johnny Richard Subject: [PATCH olang v1 2/3] lexer: add token comma Date: Tue, 24 Sep 2024 00:19:59 +0200 Message-ID: <20240923222229.151017-3-johnny@johnnyrichard.com> In-Reply-To: <20240923222229.151017-1-johnny@johnnyrichard.com> References: <20240923222229.151017-1-johnny@johnnyrichard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-Flow: FLOW_IN X-Migadu-Country: NL X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -4.00 X-Migadu-Queue-Id: 54F7767FDD X-Spam-Score: -4.00 X-TUID: OSWQWOMbN+Yy Signed-off-by: Johnny Richard --- src/lexer.c | 6 ++++ src/lexer.h | 1 + tests/olc/0027_function_with_params.ol | 41 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/olc/0027_function_with_params.ol diff --git a/src/lexer.c b/src/lexer.c index ebc21b7..6fe0151 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -227,6 +227,11 @@ lexer_next_token(lexer_t *lexer, token_t *token) lexer_skip_char(lexer); return; } + case ',': { + lexer_init_char_value_token(lexer, token, TOKEN_COMMA); + lexer_skip_char(lexer); + return; + } case '{': { lexer_init_char_value_token(lexer, token, TOKEN_OCURLY); lexer_skip_char(lexer); @@ -289,6 +294,7 @@ static char *token_kind_str_table[] = { [TOKEN_OPAREN] = "(", [TOKEN_CPAREN] = ")", [TOKEN_COLON] = ":", + [TOKEN_COMMA] = ",", [TOKEN_OCURLY] = "{", [TOKEN_CCURLY] = "}", [TOKEN_PLUS] = "+", diff --git a/src/lexer.h b/src/lexer.h index 717d21d..2746e3e 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -73,6 +73,7 @@ typedef enum token_kind TOKEN_OPAREN, TOKEN_CPAREN, TOKEN_COLON, + TOKEN_COMMA, TOKEN_OCURLY, TOKEN_CCURLY, TOKEN_EOF diff --git a/tests/olc/0027_function_with_params.ol b/tests/olc/0027_function_with_params.ol new file mode 100644 index 0000000..f70fe7c --- /dev/null +++ b/tests/olc/0027_function_with_params.ol @@ -0,0 +1,41 @@ +# Copyright (C) 2024 olang mantainers +# +# 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 . + +fn main(argc: u8, argv: u64): u8 { + return 0 +} + +# TEST test_contains_tokens WITH +# ./0027_function_with_params.ol:16:1: +# ./0027_function_with_params.ol:16:4: +# ./0027_function_with_params.ol:16:8: <(> +# ./0027_function_with_params.ol:16:9: +# ./0027_function_with_params.ol:16:13: <:> +# ./0027_function_with_params.ol:16:15: +# ./0027_function_with_params.ol:16:17: <,> +# ./0027_function_with_params.ol:16:19: +# ./0027_function_with_params.ol:16:23: <:> +# ./0027_function_with_params.ol:16:25: +# ./0027_function_with_params.ol:16:28: <)> +# ./0027_function_with_params.ol:16:29: <:> +# ./0027_function_with_params.ol:16:31: +# ./0027_function_with_params.ol:16:34: <{> +# ./0027_function_with_params.ol:16:35: +# ./0027_function_with_params.ol:17:3: +# ./0027_function_with_params.ol:17:10: +# ./0027_function_with_params.ol:17:11: +# ./0027_function_with_params.ol:18:1: <}> +# END + -- 2.46.0