From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32507 invoked from network); 20 Nov 2021 15:05:17 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 20 Nov 2021 15:05:17 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 0C7EA93D9C; Sun, 21 Nov 2021 01:05:11 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 93D5193D62; Sun, 21 Nov 2021 01:03:17 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=dartmouth.edu header.i=@dartmouth.edu header.b="b0hZNFxK"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 5437A93D61; Sun, 21 Nov 2021 01:03:14 +1000 (AEST) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by minnie.tuhs.org (Postfix) with ESMTPS id 75C5F93D5E for ; Sun, 21 Nov 2021 01:03:13 +1000 (AEST) Received: by mail-wr1-f49.google.com with SMTP id i5so23646947wrb.2 for ; Sat, 20 Nov 2021 07:03:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dartmouth.edu; s=google1; h=mime-version:from:date:message-id:subject:to; bh=YWmUnnhP31hqaL90rtIT6+wsXCSiS258vqkDC9uDw4Q=; b=b0hZNFxKmyU1gROuV8eLrXIC/1qt1DOTSUpUUCaHd2RX+ZoACtQr4bTG1xFQ4n+CUn QJfO/b6ot0eWOY45tJN4nzrKQZvbqGRR2lA7rKnSvIY1jiKX9NG5nABJbUYnUSpkGRWh IEGoh0GhH26mUIt2dLHpnpbx8kmk83Q/B6e5Gy8DGBs1A8cjHpOLxVzyXZ1nXbxIHGKS quQKRo1O7miQF4Qp9sYz4IoR+N4an2OANerZfuS5TVntO+En4v8f5daV3Y21fFBQFcVv uVq0zdbJn9hzRbgQFoguYur8xiBoe1CLb1aqOgB59GeJysl3GvG7+u5c4OqjJbdLbo2I aWbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YWmUnnhP31hqaL90rtIT6+wsXCSiS258vqkDC9uDw4Q=; b=V7LWSGl3RXkBFNpMrcXkVKYg8vnNqul6D4LbtwHldW719ixrHwzTBDoiHkA3RXtDK8 CTACtwAzmKb9HikAK0UZIdRyH6KHsUY8xTwNxK5juwYlIa7CjGxXCxWrOdNsS+cxi9nw dJlL/i4ejgj4KwnlfgXs66SlYr4s4Dgw33GyhLKT0A1NSzAyx/7QLBqitcUvd14F3UdH oT2np/rcly7jJB349nOKULktjuPgZdRk4K6S92l+M+oLUk+CRbD1bEpDY/elkIWf3AeC bq5LSKORcf4oAYlUe51nitOmLGUzyTBTe3h7fRVvQuDw1ElMbSv896WMH06krHnBy+ei 9n0g== X-Gm-Message-State: AOAM532U1X7csBjzUWSk/DXYgvXUump4JczryEeLLffwQhcHwQA+/Fdv YCQ4TjrdxPe1xJEV+GhBPLRT6/GovIKdn3IPs/SWyEYWxb7bEA== X-Google-Smtp-Source: ABdhPJwo6wRWtVmXTJ24HQBvh2/INEl3R3K8LpZeYMLC9eZ3MxjubmOHqJ/Lmhq2O+PMfa2CDrUnKCAJ2/8hYV+t4o0= X-Received: by 2002:adf:fe4b:: with SMTP id m11mr18147542wrs.136.1637420591579; Sat, 20 Nov 2021 07:03:11 -0800 (PST) MIME-Version: 1.0 From: Douglas McIlroy Date: Sat, 20 Nov 2021 10:02:56 -0500 Message-ID: To: TUHS main list Content-Type: text/plain; charset="UTF-8" Subject: Re: [TUHS] Recreation of the PDP-7 UNIX TMG compiler compiler X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" > I was deeply motivated by TMG. The good news is that you could say what > you wanted and it just did it. The bad news was the error handling. > Because it was recursive if you made a syntax error the program > backtracked and tried again. And again. And again. And eventually was > back at the first character of the input with nowhere to go. So it > issued one of its two messages -- "Syntax Error". This is somewhat of a caricature. If one's compilation strategy were to build an abstract syntax tree of the whole source program before emitting any object code, then things would go as Steve describes. In reality, TMG wasn't used this way. For one thing, ASTs needed too much memory. In TMG one could emit code while parsing. Typically code was generated on a statement-by-statement basis. This limited the backtracking, so even a naive "syntax error" diagnostic could be localized to the statement level. Long-distance connections, such as the branch labels in a nest of if statements, could nevertheless be realized recursively. Thus, in actual use, a TMG "grammar" was partly a parsing program and partly abstract specification. The balance of viewpoints was left to the discretion of the grammar's author. Yacc swung the pendulum toward the abstract. Doug