Compiler design for a fp language of following syntax

終了済み 投稿 Oct 4, 2008 着払い
終了済み 着払い

$0In this project, you need to implement a compiler for a language defined in this handout. The$0$0programming language you need to use is C or C++ (and the language defined by the$0$0corresponding tools). The project includes three phases, lexical analysis, syntax analysis, and$0$0code generation. In the following, we first define the language syntax and tokens. The definitions$0$0are given in BNF form. After the language definition, the three phases of the project are specified$0$0$0$0$0$0Define the tokens in the FP language in lex definitions and feed it to lex to generate a scanner$0$0(lexer). Then, use the sample program as well as other testing programs written in FP to test your$0$0scanner. Note that it is your responsibility to convert the BNF (or verbal) definitions to lex$0$0definitions. The tokens in FP include:$0$0The set of keywords: Program, Function, return, if, then, else, while, do, or, and.$0$0The set of special symbols: {, }, (, ), =, +, ??", *, /, %, ==, >, <, >=, <=, !=.$0$0The set of other tokens: identifier, integer, float, character-string, Boolean.$0$0It is also your responsibility to insert appropriate statements in your lex definition file so that the$0$0lexer (created by lex) will generate a symbol table and print the output token names/values$0$0appropriately. You should design the symbol table such that it contains the necessary fields for$0$0this as well as the future projects. The token names should be clearly printed, one on each line, in$0$0the correct order. The names of the tokens should conform to those given above. The original$0$0symbols for the predefined functions and the comparison-operators should be used as the token$0$0names (such as >=). The keywords itself should be used as token names (such as while). For “the$0$0other tokens??, the specific names: identifier, integer, float, character-string, and Boolean should$0$0be used. Note that for “the other tokens??, you should output the token names as well as the$0$0“texts?? you obtained (in the same line). If you do not keep track of the original texts, such as the$0$0identifier’s name, the integer’s value, the actual character string, etc., then, the information will$0$0be lost.$0$0

## Deliverables

$0The standard platform for this project is the university Sun system, including the servers and$0$0workstations such as apache. You should make sure that your program runs on these platforms.$0$0You need to submit your program before midnight of the due date (check the web page for due$0$0dates) through WebCT. Your submission should include the following items.$0$0?? The lex definition file for FP language. The file name should be “FP.l??.$0$0?? A file containing a sample program written in FP language that you have tested with the$0$0scanner generated from your lex definition file. The file name should be “[url removed, login to view]?. If$0$0you have multiple sample files, you can name them “[url removed, login to view]?, “[url removed, login to view]?, etc.$0$0?? A readme file that explains how to interpret your output from lex (the list of tokens).$0$0Also, if you have some information that you would like the TA to know, you can also put$0$0it in this file.$0$0?? The optinal [url removed, login to view] file that contains the description of some special features of your$0$0project that is not specified in the project specification, including all problems your$0$0program may have and/or all additional features you implemented.$0$0You are responsible for generating your own testing programs and test your project thoroughly.$0$0We will use a different set of FP programs for testing.$0$0If your program does not fully function, please try to have partial results printed clearly to obtain$0$0partial credits. If your program does not work or it does not provide any output, then there will$0$0be no partial credits given. If your program does work fully or partially but we cannot make it$0$0run properly, then it is your responsibility to make an appointment with the TA and come to the$0$0department to demonstrate your program. According to the problems, appropriate point$0$0deductions will apply in these situations.$0$03 Second Phase -- Syntax Analysis Using yacc$0$0For the second project, you need to define the FP-language in yacc definitions and feed it to yacc$0$0to generate a parser. Your definitions should follow the BNF given earlier, but exclude the token$0$0definitions which have already been processed by lex and instead use the token names you$0$0defined for the first project. You also need to generate a parse tree for the input FP program. For$0$0parse tree generation, you need to write code in the definition file for tree node generation. Also,$0$0you need to use a stack to keep track of the tree nodes so that you can link them properly into the$0$0correct parse tree. You can either use yacc stack or your own stack for this purpose.$0$0Each node in your parse tree should include the actual symbol of the node, including all those$0$0defined in the BNF for the FP language (e.g., +, “Program??, argument, return-arg, statement,$0$0statements, if-stmt, etc.) For each identifier, instead of giving the actual identifier name, it should$0$0simply be a pointer to the symbol table (the index of the symbol table).$0$0You have created a symbol table in the first project. Now you need to make sure you can access$0$0it and add more information into it. In this phase, you need to assign identifier type to each$0$0identifier. Identifier types include:$0$0program-name$0$0function-name$0$0argument$0$0return-arg$0$0assignment-id: the identifier in the assignment statement and is to be assigned a value$0$0expression-id: appear after comparison operators or Boolean operators$0$0parameter: all other parameters besides those listed above$0$0At the end (best is in the main program), you need to print out two things: the symbol table and$0$0the parse tree. For the parse tree, print it in the “pre-fix?? order with indentations. Each node of$0$0the tree should be printed on one line. After you print a tree node, its child nodes should be$0$0printed following it with indentation and the indentation should be 2 blank spaces from the$0$0parent starting column.$0$0For your symbol table, please try to print each identifier in the table on one line. In each line,$0$0first print the identifier name, followed by the identifier type, then followed by any other$0$0information you have put in the table.$0$0Please note that in the lexical analysis in Project 1, you may have processed some tokens too$0$0early and it may cause incorrect processing of the input program. You may have to revise the lex$0$0definition file and push some of the processing to be done at the yacc level. It is your$0$0responsibility to find the problems and make the changes.$0$0You can use the sample program as well as other testing programs written in FP to test your$0$0parser. Note that it is your responsibility to thoroughly test your program.$0$0The standard platform for this project is the university Sun systems, including the servers and$0$0workstations such as apache. You should make sure that your program runs on these platforms.$0$0You need to submit your program before midnight of the due date (check the web page for due$0$0dates) through WebCT. Your submission should include the following items.$0$0?? The yacc definition file for FP language. The file name should be “FP.l??.$0$0?? A file containing a sample program written in FP language that you have tested with the$0$0scanner generated from your lex definition file. The file name should be “[url removed, login to view]?. If$0$0you have multiple sample files, you can name them “[url removed, login to view]?, “[url removed, login to view]?, etc.$0$0?? A readme file that explains how to interpret your output from lex (the list of tokens).$0$0Also, if you have some information that you would like the TA to know, you can also put$0$0it in this file.$0$0?? The optinal [url removed, login to view] file that contains the description of some special features of your$0$0project that is not specified in the project specification, including all problems your$0$0program may have and/or all additional features you implemented.$0$0If your program does not fully function, please try to have partial results printed clearly to obtain$0$0partial credits. If your program does not work or it does not provide any output, then there will$0$0be no partial credits given. If your program does work fully or partially but we cannot make it$0$0run properly, then it is your responsibility to make an appointment with the TA and come to the$0$0department to demonstrate your program. According to the problems, appropriate point$0$0deductions will apply in these situations.$0

C プログラミング PHP

プロジェクトID: #3281690

プロジェクトについて

2個の提案 リモートプロジェクト アクティブ Oct 14, 2008

2人のフリーランサーが、平均$38 で、この仕事に入札しています。

ROWS

See private message.

$25.5 USD 14日以内
(172件のレビュー)
6.8
miguelabate

See private message.

$51 USD 14日以内
(21件のレビュー)
4.5