Re: Example interpreter C

George Neuner <gneuner2@comcast.net>
10 Sep 2005 12:37:00 -0400

          From comp.compilers

Related articles
[5 earlier articles]
Re: Example interpreter C gneuner2@comcast.net (George Neuner) (2005-08-24)
Re: Example interpreter C Markus.Elfring@web.de (2005-08-24)
Re: Example interpreter C der_julian@web.de (Julian Stecklina) (2005-08-31)
Re: Example interpreter C j_simon@gmx.at (Joerg Simon) (2005-09-02)
Re: Example interpreter C lfinsto1@gwdg.de (Laurence Finston) (2005-09-07)
Re: Example interpreter C boldyrev+nospam@cgitftp.uiggm.nsc.ru (Ivan Boldyrev) (2005-09-10)
Re: Example interpreter C gneuner2@comcast.net (George Neuner) (2005-09-10)
Re: Example interpreter C lfinsto1@gwdg.de (Laurence Finston) (2005-09-14)
Re: Example interpreter C boldyrev@uiggm.nsc.ru (Ivan Boldyrev) (2005-09-17)
| List of all articles for this month |

From: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: 10 Sep 2005 12:37:00 -0400
Organization: Compilers Central
References: 05-08-055 05-08-062 05-08-073 05-08-084 05-09-025
Keywords: design, interpreter
Posted-Date: 10 Sep 2005 12:37:00 EDT

On 7 Sep 2005 13:13:09 -0400, Laurence Finston <lfinsto1@gwdg.de>
wrote:


>> >however I didn't need it to implement loops and conditionals. If they
>> >require an Abstract Syntax Tree, then I must have implemented one without
>> >knowing it.
>>
>> It depends. [...]
>
>I apologize for my flippancy.


No need to apologize, I honestly didn't think about the tone of your
message at all. I just thought to point out that ASTs aren't
necessary so it was quite possible that your solution could avoid
using them.


For example, using only recursion and scoreboarding it is quite easy
to interpret a language which has conditionals and looping. The
recursion itself could be implemented using loops and explicit
tracking data structures, so a novice programmer might not even
realize that the solution was recursive.


[More than a few times I've seen an inexperienced [but imaginative]
sequential programmer reinvent manual recursion. It's a great
teaching opportunity because they are usually amazed at how much of
their code is devoted to emulating real recursion.]




>When I get the opportunity, I will certainly look up Abstract Syntax
>Trees.


The term "AST" itself is rather specific to translation, you won't
encounter it much in literature about other areas of programming.


Fundamentally an AST is just a data structure used to record essential
information about the input - its structure, value and meaning - while
eliminating non-essentials such as syntax and encoding.




>I do sincerely believe that basic programming skills and common sense
>are the most important ingredients in solving any programming problem
>...


It's important to have a solid grasp of fundamental data structures,
algorithms and problem solution methods ... to recognize situations
where they are applicable, to be able to compose them, and to be able
to decompose problems in terms of them.


You also need to understand the computational complexity of a solution
- that is, how it will scale with problem size. An important skill to
learn is how to analyze complexity and estimate the effects of using a
particular solution in a particular circumstance.


WRT common sense ... unless you are a wunderkind, you are likely to
find that your intuition will often be wrong until you gain some
experience. Learn how to analyze algorithms, make estimates of
performance and then compare your estimate to the reality of your
finished program. When you can reliably make good estimates, that's
when you'll know your programming intuition is calibrated and working.


Best of luck,
George


Post a followup to this message

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