"Compiler" Stanford Open Class study 2

Source: Internet
Author: User

02-01

will be for teaching language cool compiler, the cool compiled into MIPS assembly language. Will be divided into five parts to explain, the first is to write a cool program, the program itself will be an interpreter. This is followed by lexical analysis, syntactic analysis, semantic analysis, and code generation. These parts are separated. That is, when we implement our own parsing, we embed our own completed parts into a reference compiler. There are already other parts in the reference compiler. This makes it easy to exclude errors independently of each part.

Some cool code examples to familiarize yourself with the cool language.

class main{   Main (): Int {1};};
class main{   <- new IO;   Main (): Int {{i.out_string ("Hello world!\n"1;}};  };
class main{   <- new IO;   Main (): IO {i.out_string ("Hello world!\n")};  };
class main{   <- new IO;   Main (): Object {i.out_string ("Hello world!\n")};  };
class main{   Main (): Object {(new IO). Out_string ("Hello world!\n" ) };  };
class Main inherits IO {   Main (): Object {self.out_string ("Hello world!\n"  ) };  };
class Main inherits IO {   Main (): Object {out_string ("Hello world!\n"  ) };  };

Compiler method: Assume that the code name is 1.cl, the following two lines of code can be run.

11. s

After note: This point of things to see two hours ah, this is where the computer class, which is clearly foreign language class Ah, fell!

"Compiler" Stanford Open Class study 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.