Re: magic/absurd bash interpreter/compiler ?

glen herrmannsfeldt <gah@ugcs.caltech.edu>
Tue, 25 Dec 2012 03:25:01 +0000 (UTC)

          From comp.compilers

Related articles
magic/absurd bash interpreter/compiler ? Avoid9Pdf@gmail.com (2012-12-23)
Re: magic/absurd bash interpreter/compiler ? miller@yoyo.ORG (J G Miller) (2012-12-24)
Re: magic/absurd bash interpreter/compiler ? jthorn@astro.indiana.edu (Jonathan Thornburg) (2012-12-24)
Re: magic/absurd bash interpreter/compiler ? eric@deptj.eu (Eric) (2012-12-24)
Re: magic/absurd bash interpreter/compiler ? barmar@alum.mit.edu (Barry Margolin) (2012-12-24)
Re: magic/absurd bash interpreter/compiler ? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2012-12-25)
Re: magic/absurd bash interpreter/compiler ? eric@deptj.eu (Eric) (2012-12-26)
Re: magic/absurd bash interpreter/compiler ? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2012-12-28)
Re: magic/absurd bash interpreter/compiler ? barmar@alum.mit.edu (Barry Margolin) (2012-12-28)
| List of all articles for this month |

From: glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups: comp.compilers,comp.unix.shell,comp.os.linux.misc
Date: Tue, 25 Dec 2012 03:25:01 +0000 (UTC)
Organization: Aioe.org NNTP Server
References: 12-12-014 12-12-018
Keywords: interpreter, design
Posted-Date: 25 Dec 2012 18:16:49 EST

In comp.compilers Eric <eric@deptj.eu> wrote:


(snip)
> Why on earth would you expect all computer languages to parse with a
> single pass from left to right? Neither Pascal nor Forth is a typical
> computer language. Pascal has more-or-less the sort of parser you seem
> to think should be universal, Forth does not! Bash (like other shells)
> is an interactive command-line based user interface which can also be
> used to write scripts, and it has evolved over many years, so why would
> it be like that?


(snip, our moderator wrote)
> [I've had a lot of questions from people who seem unclear on the
> difference between an interpreter and a compiler, and get confused as
> soon as the language gets complex enough that it can't be handled a
> line at a time by read-parse-interpret. Most languages I know can indeed
> be parsed in a single left to right pass, but all you have at that point
> is a parse tree, with a lot of the compiler's work left to do. -John]


There are many interpreted languages that pretty much can't be
compiled, at least in the usual sense of compilation. Especially in
shell languages, but also ones like TeX and Mathematica, where you can
expand variables to be keywords that are then parsed.


I once wrote self-modifying code in Mathematica. Someone wanted, in
the and, a Mathematica notebook with all the results and graphs, but
not with the Mathematica code. I wrote the code that asks the front
end to delete the code from the notebook. (Be sure to save before
testing during debugging.)


TeX has \expandafter which allows for run-time generation of names of
macros to execute.


One problem with many unix shells is that redirection is done too early.
Specifically, before an if test is done.


-- glen


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.