Font Size: a A A

The Design And Implementation Of Symbol Table And Attribute Grammars Of C Compiler

Posted on:2017-02-10Degree:MasterType:Thesis
Country:ChinaCandidate:C LiuFull Text:PDF
GTID:2308330485487990Subject:Computer technology
Abstract/Summary:PDF Full Text Request
After half a century of research and practice, it has achieved the hodiernal compilation technology. In modern computer science, compiler is one of a handful of the areas that abstract concept completely change the way of programming and is one of the most important applications of modern computer technology. The design of the symbol table is an irreplaceable part of the compilation techniques. Studying and researching the symbol table technology, and to be practical, are of great significance.The thesis briefly expounds the lexical analysis and syntax analysis, which paves the way for the realization of the symbol table. It analyzes the design and implementation of the symbol table of the block-structured language for C compiler from the perspective of the attribute grammar.First, the thesis illustrates attribute grammar is a context free semantic extended grammar, which provides a practical representation mode of the description of the semantic processing, elaborates the process that the method based on attribute grammar describes syntax directed translation, and analyzes the attribute information flow direction syntax tree nodes represent. Attribute grammar makes use of the syntax tree in the syntax analysis phase represented as the intermediate representation of the identifier information. The compiler adopts the realization scheme from the left to the right, from the bottom of attribute flow direction over the way to be translated directly. The thesis puts forward simple method of the nonterminal for attribute evaluation function, so that the grammar has better readability.Second, the symbol table system is designed and implemented based on the idea of using analysis tree nodes to explain the attributes and the characteristic information from bottom to up. In the process of compiling and analyzing, the task of the symbol table is to correctly record all names of the attribute and characteristics in the source code and continue to collect information, to repeatedly search for different name references in the compilation process. This thesis introduces the realization of the symbol table organization method, elaborates the rules of identifier visibility and the scope rules, and then gives the overall logical hierarchy of the symbol table, analyzes the relevant data structure design of the symbol table, and provides the visible interfaces related to the symbol table in other components of the compilation process.Third, this thesis deeply analyzes the information structure and using methods of the types, arrays, structures, variables, functions and so on in the symbol table, puts forward an idea constructing complex type by the type chain, and accomplishes data composite type algorithm and the initialization algorithm. According to the C99 standard grammar, constructing the grammar structure and designing the basic framework of the symbol table apply for all of the C language compiler front-end architecture.Finally, the results obtained by the experiment and test are the same as the expected results. Currently, the realization of the current symbol table still has many shortcomings, and the thesis proposes feasible improvement plans in the process of the follow-up research and development.
Keywords/Search Tags:compiler, attribute grammar, symbol table system, type chain, C99
PDF Full Text Request
Related items