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 AC2nFzoCCGcHJAEAe85BDQ:P1 (envelope-from ) for ; Thu, 10 Oct 2024 18:35:06 +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 AC2nFzoCCGcHJAEAe85BDQ (envelope-from ) for ; Thu, 10 Oct 2024 18:35:06 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=Vsw47qEC; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=foeC8iia; 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=1728577788; a=rsa-sha256; cv=pass; b=c9dEOGhzyGSsPb3MaihPWGcp21pXiys574W46FdPCcjb+jc3nNvJCTGCPcxK1v3BR8kFRP /PH+VCTluJalHJvTcFcKxmt31iyiVM+5alsikXU082F6Us7LQ8XBPeeYEiIgZY932fIxeg 39BvqdsTnllE6VK+h/pl2s+/5W2q+cIB+lcI8EhJuC/67iUv8stJzEO5bBeAiL7ziSK5+H gIDBuzbkFb+44FbtoyRKKeLDRix0zYnTaKX4TViRo2C2n+qZBUpZuGaY1HaThZ3/vf46TV rGgoo6vzlvSsrXgVMiepksQ0rDFxQUw5I6WdHOPCF35BbBxgmYRx86mLLO26JQ== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=Vsw47qEC; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=foeC8iia; 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=1728577788; 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: in-reply-to:in-reply-to:references:references:list-id: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=5ibWS0lYErImSvUEDFb2mtvW8OvkFw+M0AAFH3eSayY=; b=Lbj0K7y9M9NdUwx8olNnOgXgDceyeAVNLbyGycMpVsRzYjWhkcCSP66RoA7Pur5qC56vmx VG4CncSg6gQ0fbVuXmi8TY9hu8ztTyozRcsM7YdDCBOVoZyywqeFJIP3X3yn/d1X6p/a8L T64wJAKFxDCtYMx7LWG7MeQLF1sFXTvfg7cL/nYBNe21O08GUuIEaKAOxr6Kwvjp8OXSVg yXn+mEPvgRq0iKkNC0GVVfG4SzfcEBgF1MXtHtm+bXGqsp6MLqMt+7AvF2PnZqGd3w5BPZ fD3GMjEdDiRAYCWFUNjkKy2XImdwULsneIn5khrA80QCG0t23R6k6mfhC7qwgQ== 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 655B337545 for ; Thu, 10 Oct 2024 18:29:48 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=wfoNj/X3bHuvcbVR0FnLJETjAvtrqH0YUW7nlgbiLS4=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:In-Reply-To:References:Date:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1728577788; v=1; b=Vsw47qECfnj8yzMGnj0ZukMtIiJwlU+48Og3dswb2cRB55X/dQmRN1ZP2aK1PT3uwcWanSF+ XKoOQTg6tugPiFr0wWY/LVxLElDoIzwNVPmhS8XFJfcVAPrNQAMdXtWUiMXMtGVRX23tqhQycJG YByaV+2wYRIs0W7pnP78IoKZI6lXOrZZuZnhTrnWDhpNSu4fRAeM7B72Ce+/F/KYt8ZjpHoomzo JX4GtZ3KHn573eOUz8UEeCYaYIn/Q94N0BNyt9nzIFTeYuzNzXXG0oc1u3sOuOlZ1bgt0SJdOwD 0KmMWLG+mAupTdqF8WY+9AzbnpDuATr5sQF9b7x1v3UQA== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id 3672420218 for ; Thu, 10 Oct 2024 16:29:48 +0000 (UTC) Received: from caracal.birch.relay.mailchannels.net (caracal.birch.relay.mailchannels.net [23.83.209.30]) by mail-a.sr.ht (Postfix) with ESMTPS id 7D395201E1 for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 10 Oct 2024 16:29:46 +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 094827833F1 for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 10 Oct 2024 16:29:38 +0000 (UTC) Received: from nl-srv-smtpout1.hostinger.io (trex-0.trex.outbound.svc.cluster.local [100.96.176.246]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 6C56778349C for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 10 Oct 2024 16:29:37 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1728577777; a=rsa-sha256; cv=none; b=nkSCHnQKBnakjhs9rYoV/7TtiWM9LYANU80I+B9lRsGbP/h2nDIKnAne4ZSM95WTHU86Tv mXU1Cb4pzlTuJqom+1EuOSQh89ejhTcgLwCny5Rm2viB96MBN0zKd7Hdl89uQWNcsJPMIQ xJXogWKDzWcF+MbpX35w64OCvcCdTihxY/S1aCJQuizafcobZTuXrGoewcAIABhtmNnt0y rodFCEr48AWpY7A5ChUNjGD5YWZ4KAfUM5gladhHlCWE1G+dLJ684FZuNto46zHTJsG3fO 6MzstAbB23dJ55cQ/6ZhINO0ppMJZ6IggeMHNvy63IP1zVuC/Pwf3/lVxu9umA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1728577777; 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:dkim-signature; bh=5ibWS0lYErImSvUEDFb2mtvW8OvkFw+M0AAFH3eSayY=; b=pbZQpVhI07HGWjHGV6isWpR+xF0j4OumsRjn3mQhYuPrEpGtippte2TRlUBpSf4CenreCj 2fXmhaaP1CBcO3SfBFxhQseW97unF0/Btns7YwOJ4iR7GoyEwz+Kzeb5/VdkD8+t4VsD2w JWtmbKEfKevqgFOnbazWp39W/2O/+x9U6DmyC/4Nd4Z4sk6vxIfi+8H/D/MtT3PEDaIajz fP3JC4hV6X8lRHv12StYeh4L2eX2pPkno6CDVbHYKkZT5U8bTrrZDHQElFEUM2HN6WaH2G IhfEPO88Hm/zdisuVTn1Zm+jVhLmOnZ9mi6cgDEe/GybhZ8R6LX7xWMSjjO/jA== ARC-Authentication-Results: i=1; rspamd-5fcd6bf96c-bc64j; 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-Chief-Zesty: 4b8a5dd10a5575c3_1728577777911_3985005937 X-MC-Loop-Signature: 1728577777911:642737667 X-MC-Ingress-Time: 1728577777911 Received: from nl-srv-smtpout1.hostinger.io (nl-srv-smtpout1.hostinger.io [145.14.150.87]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.96.176.246 (trex/7.0.2); Thu, 10 Oct 2024 16:29:37 +0000 From: Carlos Maniero DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1728577775; 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=5ibWS0lYErImSvUEDFb2mtvW8OvkFw+M0AAFH3eSayY=; b=foeC8iiao+A4rlAYyoKl3K1ycuPPEzZOfpVc3aWR7Vc/RAy/9MNTN411IfLounyLrlgKiY DEluh63Cc0kbQeuH6kuZD7YyEsylql/iqOzM8S65u2YrG0H7SJfAGxZfXrPqMPkSbvfL7X pHDOcXWmY9w5tm08+Zc9c6r9+oKh6BbEvut9yT7qU5vPWY3HYR3XDfU66qpNyXxqCrLVph 4VfKVxNiyLHITmHFfwCbkAymvOe2DF05uN8MoZ12FiVL+DFekwVviCAsqMs4JQ6jCEjK39 oWE+yHpNXjq4ij7xlW7bJ4cAvHoW2J+SLpToQItFPK8I9VB0hhGrTXPECkwIrQ== To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Carlos Maniero Subject: [PATCH olang v3 2/2] parser: fix unary precedence Message-ID: <20241010162918.338338-3-carlos@maniero.me> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241010162918.338338-1-carlos@maniero.me> References: <20241010162918.338338-1-carlos@maniero.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Thu, 10 Oct 2024 16:29:34 +0000 (UTC) X-CM-Analysis: v=2.4 cv=bZY5U/PB c=1 sm=1 tr=0 ts=670800ef a=WwxFCuf3mf1fs3oSi6/dng==:117 a=WwxFCuf3mf1fs3oSi6/dng==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=mDV3o1hIAAAA:8 a=MHCnBjUnpQPb9w1OixwA:9 a=jZ3kfizBcAqmHbI0vVTV:22 a=BXDaF_L80NY05PYiAFlV:22 X-CM-Envelope: MS4xfJ8F16ArY9p6L2vp7m6JKyJyuzl5Ig2mLxEevc8FQPWWm0jDUZ5CtHsjR+dMU+7C+8dgzmWUfZSuJOmJPvltMKu3y1oVbpSoUwREmAREy+6HRWwgnhHZ zvikvU6PKeeoePl6I5iTxy56rrB4eoboQv8g6zu1CXIZDB1J85wTk9j8/nInqxCD7v8yIUCaMusWdNvc0aFPK+V1V36AMroWCwq077MaVf/ejKxCWwW28xVC 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.69 X-Spam-Score: -5.69 X-Migadu-Queue-Id: 655B337545 X-Migadu-Scanner: mx10.migadu.com X-TUID: 9cXD8VpquQci Unary is only supposed to contain primary expressions. Before this commit, the code { *a = 1 } was interpreted as { *(a = 1) }. Signed-off-by: Carlos Maniero --- src/parser.c | 2 +- tests/olc/0034_pointers.ol | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/olc/0034_pointers.ol diff --git a/src/parser.c b/src/parser.c index 44a4900..177195d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -303,7 +303,7 @@ parser_parse_factor(parser_t *parser) case TOKEN_DASH: case TOKEN_TILDE: case TOKEN_BANG: { - ast_node_t *expr = parser_parse_expr(parser); + ast_node_t *expr = parser_parse_factor(parser); if (expr == NULL) { return NULL; } diff --git a/tests/olc/0034_pointers.ol b/tests/olc/0034_pointers.ol new file mode 100644 index 0000000..3f3e80b --- /dev/null +++ b/tests/olc/0034_pointers.ol @@ -0,0 +1,43 @@ +# 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 . + +# A minimal olang program +fn main(): u32 { + var a: u32 = 1 + var b: u32* = &a + *b = 0 + return a +} + +# xTEST test_compile(exit_code=0) +# +# xTEST test_run_binary(exit_code=0) +# +# TEST test_ast WITH +# Translation_Unit +# `-Function_Definition +# `-Block +# |-Var_Definition +# | `-Literal +# |-Var_Definition +# | `-Unary_Operation (&) +# | `-Reference +# |-Binary_Operation (=) +# | |-Unary_Operation (*) +# | | `-Reference +# | `-Literal +# `-Return_Statement +# `-Reference +# END -- 2.46.1