Font Size: a A A

The Design And Implementation Of LL(1) Action Grammar Compiler's Automatic Constructor In Java Language

Posted on:2006-03-21Degree:MasterType:Thesis
Country:ChinaCandidate:H T ZhangFull Text:PDF
GTID:2168360155954425Subject:Software engineering
Abstract/Summary:PDF Full Text Request
Compiler is one of the most common tools in the computer application.It translates the language that the mankind is used to into the data structurethat the computer can understand. With the universality of computer, Compilercompilers are used in more wide fields. It is valid tool of generatinglanguage processors (such as compilers translator or interpreters ) fromhigh-level descriptions. you specify the grammar of your language, and thecompiler create a program that process the input text written in yourlanguage. This program decomposes the input into phrases. For each kind ofphases ,you can attach semantic actions to your grammar which are elaboratedwhen the corresponding phrase is processed. Technology form compilerconstruction become more and more important in fields of domain specificlanguages, document processing, and automatic software generation. Theprocess of analyzing compiler is usually that the Lexical parser read the tokenof the source program one by one first, then the Syntax parser set up thesource program's syntax structure after reading the token stream from Lexicalparser. Accord with syntax structure, Semantic parser analyze and check theprogram's static semantic character . Lexical parser , syntax parser andSemantic parser are the basic composition of the compiler. Further ,it alsohave Intermediate Code Generator ,Code Optimization Generator and CodeGenerator if it is designed for advanced program language.Now compiler are guided by syntax ,So you have finished main taskwhen you have analyzed syntax .Syntax analysis table can be worked fromtop to bottom and it is normal from bottom to top . Semantic Analysis andIntermediate Code Generate are Careful and complicated parts of compiler ,Sothese parts are described in more normal and more abstract means. Currently,programs are defined grammar,which contain grammar and semantic action.It not only make it simple but also make it automatic. So the way are called asaction method .Action method are usually used in describing syntax action.What my thesis do is to design a compiler compilers for grammaranalyzed by LL(1) method in java language. The complier's constructor willbe finished needs to deal with source files twice. lexical analysis first ,syntaxanalysis next. The input of program is a file written in defined grammar,which contain grammar and semantic action. It is made up of threeparts ,syntax parser class name, lexical rule, syntax rule. The grammar of theinput file can be analyzed by LL(1) method, so we create the storage structureof the input file in recursive-down method, and then we compute thenonterminals that can deduce empty, the first set of every nonterminal, thefollow set of every nonterminal, and the predict set of every rule, in theend ,we judge whether the intersect of any two rules of any nonterminal isempty, if it does, we conclude that the grammar can be analyzed by themethod of LL(1). If the grammar can be analyzed by recursive-downmethod ,we should have a buffer to save token stream and have a tokenindicator to indicate current token. Of course ,it is necessary to have a parserexception to deal with all kinds of exception. Base on them, the systemproduce corresponding syntax analysis program. So the results are wehave expected..The thesis are written in LL(1) method .On the other hand ,The LALR(1)method efficient in time and space and cover a large of grammar. So the mostof the compiler compilers is designed for grammar, few for Grammar which...
Keywords/Search Tags:Implementation
PDF Full Text Request
Related items