[Yui compiler story 1 -- before zero]

Source: Internet
Author: User

This semester, I started a long-awaited course, compiling principles, just like returning to the sophomore operating system course. I was full of expectations but lamented my lack of strength, A few header files, you can get yourself dizzy.

The first experiment was completed yesterday to implement a simple lexical analyzer. A lot of students have uploaded their ownProgramLong GE's album name is very interesting. from scratch, I think I haven't even reached even zero. At least now, right? So the title is simply called before zero.

I am a technical controller. I want to be my own webface, and I want to be my own lbs, and I want to be my own compiler. Right is a hobby, I want to use my own logs to record the growth process of this compiler. I call it Yui to commemorate my college days. I have a code in each phase of my own. This Yui was originally from the English name of Xin Yuan Jieyi and also the name of a Yahoo JS framework, but in fact these are not important, it indicates a state. Yui may succeed. Of course, it may fail. If I don't go crazy in the future, it will still fail in 99%.

I hope that one day Yui will expand to a large number of open-source enthusiasts, which is such a Saturday morning dream.

----------------------- Technical split line -----------------------------------------------------

Wang Hongzhi divides the course into several modules, including lexical analysis, syntax analysis, semantic analysis, and optimization. I recently read more about lexical analysis. I handed in my first experiment yesterday. I was accidentally praised by him. I was taken as an example. I was surprised to hear that. The good thing is that the program structure of lexical analysis is clear. In fact, it is easier to use a DFA process as the program structure, therefore, selecting process-oriented C language is a good idea, but object-oriented language also has its advantages. The bad side is also the structure of the program. In fact, I still feel very confused. I have been thinking about the reason. On the way to breakfast today, I understand, because lexical analysis is not doing his job. For example, because matching judgment such as parentheses is introduced in the lexical analysis phase, the original structure is damaged, and matching of parentheses is what the syntax analyzer needs to do according to grammar. Think of the Linux KISS Principle, keep it simple and stupid. Focus on a task to do this task. Therefore, you must pay attention to the syntax analysis in the next stage.

 

---------------------- Yui-0.11 update -----------------------------------------------------

 

Development language: c89

Environment: Unix cygwin

Compiler: gcc

////////

Function: reports an error.

Obtain the token Sequence

Symbol table maintenance

Error: the keyword is incorrectly defined (Standard c89)

{[(/* Brackets matching problem (this function is simplified)

Supported keywords: 9

Operator: 30

Constant: character, integer, floating point

BUG: Chinese, Escape Character Processing

 

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.