From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Nikolay Kudryavtsev Newsgroups: gmane.emacs.help Subject: Re: SMIE grammar for C-style function expressions Date: Tue, 28 Sep 2021 14:47:32 +0300 Message-ID: <1a33ce2e-7083-5b2e-b063-a897b118e21a@gmail.com> References: <8c6fc2a9-1086-c026-459d-1e703563ae1d@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39922"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Cc: "help-gnu-emacs@gnu.org" To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 28 13:48:37 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVBbB-000AD6-0Q for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Sep 2021 13:48:37 +0200 Original-Received: from localhost ([::1]:53478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVBb9-0007dk-Br for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Sep 2021 07:48:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVBaD-0007Zx-9l for help-gnu-emacs@gnu.org; Tue, 28 Sep 2021 07:47:37 -0400 Original-Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]:44779) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVBaB-0004lk-F5 for help-gnu-emacs@gnu.org; Tue, 28 Sep 2021 07:47:37 -0400 Original-Received: by mail-lf1-x12d.google.com with SMTP id y26so52011975lfa.11 for ; Tue, 28 Sep 2021 04:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=IES7CSD8vcORDqjKx+FCSJWb3jLHJgexezO8xRmRLCk=; b=RrPhwGdeoJ7JGwJyIDej/+xJ1YWbdwk1o/lQg3zfENvsb6uOddfB5a5fs4mepf2e5X 7MJ6YV7IYoCYJv6YFQ7WjSydMPRl8meUfTlPA5N1r1lpG7dj+CxhOZ2UrppeP2tKD/hJ VU/iy/1Tfp5XvRfaiW5g8R6nnm6pGLe4kbdeP3EjyOkwwepyf1s7LiuBcEERd6WxOXmi 21aOAT5xrVN7f2Z8G9xwmXf8aTfawCiFYKYplMnbgP4OwtGt7vfbpjed3O0Eof3hbujQ EVmsGcznhJdbGwITpCfnqTNFR5xsAnN+Kg9D4cxXcZie/pHA+E52Z/rywws6o++cmC/h +crQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=IES7CSD8vcORDqjKx+FCSJWb3jLHJgexezO8xRmRLCk=; b=eZhmOPfpjEJ9WDXipxzUzbvEKB2r/ll6tI0bVC7VpCC4yWe7n1uRKU+vlFg0U2KJdc tsEAsqPA66uUwGOwaB6qFPX7AaWMnX46XqrWu1qcHvG/KWy85FrXDrmYjSYWIfsJJi49 SajLcLOW2cT/u698RJS7JAZJBz+7JWNHB1+Bh28FEWkhFnpDUWxmzIriWHkLeyThIGQn BGyxyJCz6bXXSSYb7Jei3Xvgt1PvKeffGGG2svb8XJuQta3qGARYFmkv1bbymnyeFiOw mKSZBpx2rwFj4InCrWGVtxhIowsX0F+UqSrD0CWd9OHY5WA//VbkNwTB/F9U5uSdukqY rcYg== X-Gm-Message-State: AOAM530yfQ/rfvD+hbQXoItSzUOW0z3iIywygVL8bSOYI1DHu5udNzv8 0DipXplnXW1VMqvh//eO8MsJjNCauGc= X-Google-Smtp-Source: ABdhPJyDjKRrzCSdGlggb0ShbExmLo/7SkxJOCImEfxPFh1yILd6lBQTEj5pYluarTOeivtVNtSk7Q== X-Received: by 2002:a05:651c:4ce:: with SMTP id e14mr5295354lji.511.1632829653604; Tue, 28 Sep 2021 04:47:33 -0700 (PDT) Original-Received: from ?IPv6:2a02:2168:b115:9d00:955b:6a86:1b59:12c8? ([2a02:2168:b115:9d00:955b:6a86:1b59:12c8]) by smtp.gmail.com with ESMTPSA id l26sm1900109lfh.247.2021.09.28.04.47.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Sep 2021 04:47:33 -0700 (PDT) X-Google-Original-From: Nikolay Kudryavtsev In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::12d; envelope-from=nikolay.kudryavtsev@gmail.com; helo=mail-lf1-x12d.google.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, NICE_REPLY_A=-2.562, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:133345 Archived-At: I understand that SMIE does not concern itself with the AST, but I think it's reasonable to start with describing the language grammar for it in the most naive way, until we have a good reason not to. "f n ( a ) { s }" is a single expression in the language, so someone implementing a grammar for such language may first try to declare it in SMIE as a single expression. To try and keep the problem stated in practical terms, lets say the language grammar looks like this: args = ( a ) stmts = { s } "f" n args stmts "f-end" With the point after "f-end", I want backward-sexp to put me past "f" and for this: (A)I have to keep the entire expression within a single SMIE declaration. (B)My lexer has to add some virtual keywords to separate nonterminals: "f" n " : " args " : " stmts "f-end" Is this the proper approach? Are my assumptions A and B correct? P. S. I've add "f-end" here to wave off the ambiguity caused by the last token in the real C-style expression being both main and child expression closer, since that problem, while real, is not the issue here.