Racket之第二周学习(四)Implementing Programming Languages

终于学习到了激动人心的课程,如何实现编程语言。如果能将该课程学习得滚瓜烂熟,那可真算是习得了绝世武功。

call that string the concrete syntax."(fn x=> x+4) 4"

1.first typical stage is to pass that syntax to the parsing procedure, parser.

2.Except the error messages, we'll get Abstract Syntax Tree(AST, more structured than write down).

3.And if I don't have of those, then I pass this AST onto the rest of the implementation, which is in charge of running the program and giving an answer.


There are basically two fundamental approaches to implementing some programming language

1.  One approach is I can write an interpreter in another language A.

            And the idea is to just take that syntax tree in B and come up with what the answer would be if you ran it.

2.  The second approach is to use a compiler.

          So the idea with a compiler is, it is itself of course written in another language A.And it produces a program in a third language C and then we just take that program and we run it.

           So, if C is binary code, the kind of code that your computer hardware can run directly, then you can think of the computer hardware as an implementation of C, and so your implementation of B just translates to a program in C and then, you run it on the hardware. ??????

This language A that we use to implement our language B, we'll sometimes called the metalanguage.

For example most implementations of Java start with a compiler that translates your program but not all the way down to binary, just to some intermediate language, it's often called bite code.

Then there's an interpreter for that bytecode language, but that can be a little slow and so, that interpreter includes a compiler for compiling down to hardware.

Interpreter versus compiler versus combinations is about a particular language implementation, not the language definition.

你可能感兴趣的:(Racket之第二周学习(四)Implementing Programming Languages)