Font Size: a A A

Designing And Implement Of A Compiler On Dot-NET Platform

Posted on:2007-01-29Degree:MasterType:Thesis
Country:ChinaCandidate:L J GanFull Text:PDF
GTID:2178360182496271Subject:Software engineering
Abstract/Summary:PDF Full Text Request
This paper that edits the compiler of Cs (the C simple )language ,isestablished on dot-NET platform. The frame of dot-NET is an operationsystem within the dot-NET strategic platform of future actually. It is thefoundation frame all of the dot-NET application, provide to establish,deploy and circulate the environment of dot-NET application. The frame ofdot-NET is also the key of the isomerous platform communication.According to this kind of present condition, we need urgently toresearch developed language that is not on the dot-NET platform, making itadapt for the structure request of the dot-NET platform. Thus, make use ofthe environment that is common language runtime on dot-NET platform,develop the advantage of the dot-NET platform. Carry on the language thatthe people of now use habitually, integration, carry out the orientation toacross the language, the engineering of the cross-platform carry out.Here, the language of Cs is a simple representative that is of variouslanguage, being similar to the language of C, is a subset of the C language ,it includes integer variable, integer array variable, and function, it still hasthe elucidation that is the local, globe variable and the functions that isrecursion. The Cs program structure is very simple: it is a sequence ofsentence that be separated with the semicolon only. All variable is integer。Before use must carry on the definition, just can use. Returning type ofvalue is declared in ahead of function body, it has two kinds of types: a kindof returns the type is integer, another kind of returns the type is null. It onlyhas two kinds of control language sentence: if sentence and while sentence,these two control sentences also can include a single sentence or acompound sentence.The textual work mainly includes following a few of aspect:First, introduced to the Dot-NET platform and the composing ofcompiler, and the function of each parts of module, then defined thelanguage of Cs and textual main work-how to construct a compiler. Givenprogram code structure of the Compiler, and each class of main finishedmission.The next in order, according to the characteristics of the Cs language,listed symbol set and seven kinds of sentences that that program languageconsistently use: control sentence, call function sentence, expressionsentence, assignment sentence, null sentence, compound sentence,annotation sentence. meanwhile, set up the state graph that compiler of thelanguage of Cs use lexical analyzer, introduce to the data structure of thetoken of the compiler. Give in C# ( C sharp) dot-NET how carry out lexicalanalyzer of the language of Cs. Among them, it is a little more difficult toidentify identifiers and numerals, because the numeral can appear in theidentifier, the character don't only constructed identifier.Again, set up the grammar-Backus-Naur form(BNF) according tothe language of Cs, make use of the analytical method that is recursion anddescending realization the Cs language grammar on the platform ofdot-NET, then, the token sequence that lexical analyzer create, convert tosyntax tree structure with the phrasing analysis machine. Introduced thestructure of the phrasing tree and should have some attribute in each nodeof it.Again the next in order, carry on semantic analysis to syntax tree,through once traversing grammar tree, build up symbol table, the typecheck and the function area check. Among them, the symbol table adoptedthe form of the hash table. The type check mainly check data type and datasbefore use whether it is defined. The function area check is a time limitedefficacy that the compiler check the variable of Cs language program,including the time limited efficacy between the parameter and variable,between the parameter and argument when function is called.Finally,make use of the particular character on dot-NET platform-MSIL(Microsoft Intermediate Language),convert Cs language to MSIL.Still carried out to make use of to reflect the technique, convert Cslanguage to the PE (probably execute) document. Various conversion allincluded the transformation of the declaration, sentence in functionbody(function structure defining statement, function calling statement, andjumping out of a function body), the transformation of data processingstatements, the transformation of control statement, the transformation ofthe input and output statement etc. For the sake of the function thatcompiler have a debugger at the same time, increased and can order thefunction to the Cs language procedure marking sequence in the compiler.This can carry on adjusting setting to the developed program, such assetting breakpoint, stepping, modifying program state, edit and continueetc.On the above introductive, realize on the dot-NET platform, embodyon code of program. This paper is consist of lexical analysis, syntaxanalysis, semantic analysis, intermediate code to constitute each chapter.MSIL-Microsoft Intermediate Language of this paper discussion,carry out language of Cs to the conversion of MSIL, using of to reflect thetechnique, convert Cs language as the PE (probably execute) document,and realizing debug function of the language of Cs is importance of projectthat is designing and implement of compiler on .NET platform. Just onlyintroduced in this paper how to realize the example of this kind ofconversion, the realization of the integrity is on the program code of thecompiler. Realize the compiler of Cs language, to the integration of thelanguage, across the language, the engineering of the cross-platformdevelops have the certain practical meaning.
Keywords/Search Tags:Designing
PDF Full Text Request
Related items