1. Homepage
  2. Programming
  3. COMP3173 Compiler Construction - Project Implementation - Phase 1 Lexical analysis

COMP3173 Compiler Construction - Project Implementation - Phase 1 Lexical analysis

Engage in a Conversation
UOITCOMP3173Compiler ConstructionLexical analysisC

Project Implementation CourseNana.COM

Phase 1 Lexical analysis CourseNana.COM

In phase 1, you need to implement a lexer for the language described in “COMP3173 23F Project Description.docx”. Your lexer consists of five source files: “func.c”, “lexer.h”, “lexer.c”,  “symbol_table.h”, and “symbol_table.c”. Detailed requirements are listed below. CourseNana.COM

func.c CourseNana.COM

-       It is the main entry of the entire project (all phases). CourseNana.COM

-       It opens the source program. CourseNana.COM

-       The source program is passed to the main function as an argument. CourseNana.COM

-       It makes calls to the function “next_token” defined in “lexer.h” and “lexer.c”. CourseNana.COM

-       It maintains a symbol table defined in “symbol_table.h” and “symbol_table.c” to store all the identifiers. CourseNana.COM

-       If the function “next_token” returns a token, print the token and its attribute(s) on the screen for verification purpose. CourseNana.COM

-       If “next_token” returns an error flag, report the error and its location. CourseNana.COM

-       After the entire process is finished, print out the symbol table. CourseNana.COM

lexer.h” and “lexer.c CourseNana.COM

-       You need to design and implement a DFA to complete this task. CourseNana.COM

-       To implement the DFA, you must use a transition table. CourseNana.COM

-       You must define the transition table in “lexer.h” in a proper way (for example, as a 2-dimensional constant array). CourseNana.COM

-       It reads and cuts the source program into lexemes. CourseNana.COM

-       It returns the first token which is found every time when “next_token” is called. CourseNana.COM

-       It ignores spaces, indentations, line breaks, and comments. CourseNana.COM

-       If the token is an identifier, insert the token into the symbol table. Each token has an attribute to record its memory location in the symbol table. CourseNana.COM

-       If the token is an integer literal, the token has two attributes: type, for its data type; and value, for its value. CourseNana.COM

-       If the token is none of the above, it does not have an attribute. CourseNana.COM

-       If there is any lexical error, returns an error flag to the main function. CourseNana.COM

symbol_table.h” and “symbol_table.c CourseNana.COM

-       It should be implemented as a data structure (AVL tree is recommended to search and insert symbols efficiently or you can use any data structure you want. Efficiency is not required here.); CourseNana.COM

-       Each identifier has its variable name and its type. (This language has two types of identifiers, integers and functions.) CourseNana.COM

-       The symbol table also needs a function to print out its content. CourseNana.COM

  CourseNana.COM

The implementation must be done in standard C (not in Visual C). For those who do not have standard C installed on your local computer, you can try to install MinGW from https://www.mingw-w64.org/ or use online GDB at https://www.onlinegdb.com/ . TA will use make file to check your analyzer. CourseNana.COM

  CourseNana.COM

Example: CourseNana.COM

In the package “Example.zip”, you will find all the source files described above. Currently, they are all empty. The main function simply prints the argument on the screen. The package also contains “make.bat”. You can open it by a txt reader. Then, you can see the compilation commands. CourseNana.COM

CourseNana.COM

After executing “make.bat” (suppose you are using Windows and have GCC installed), you will have “func.exe”, which is the compiled analyzer. CourseNana.COM

CourseNana.COM

CourseNana.COM

  CourseNana.COM

Suppose the source program that we want to analyze is “sample.txt”, we execute “func sample.txt”. CourseNana.COM

CourseNana.COM

  CourseNana.COM

Submission requirements CourseNana.COM

Each team need to clearly indicate the contribution of each team member in a txt file. To submit your work, you need to pack all files (source code and contribution txt) in a package. Rename the package as COMP3173_23F_TeamXX, where XX is your team number. Only team leaders need to upload the package to iSpace. CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
UOIT代写,COMP3173代写,Compiler Construction代写,Lexical analysis代写,C代写,UOIT代编,COMP3173代编,Compiler Construction代编,Lexical analysis代编,C代编,UOIT代考,COMP3173代考,Compiler Construction代考,Lexical analysis代考,C代考,UOIThelp,COMP3173help,Compiler Constructionhelp,Lexical analysishelp,Chelp,UOIT作业代写,COMP3173作业代写,Compiler Construction作业代写,Lexical analysis作业代写,C作业代写,UOIT编程代写,COMP3173编程代写,Compiler Construction编程代写,Lexical analysis编程代写,C编程代写,UOITprogramming help,COMP3173programming help,Compiler Constructionprogramming help,Lexical analysisprogramming help,Cprogramming help,UOITassignment help,COMP3173assignment help,Compiler Constructionassignment help,Lexical analysisassignment help,Cassignment help,UOITsolution,COMP3173solution,Compiler Constructionsolution,Lexical analysissolution,Csolution,