The goal of this project is to give you hands-on experience with lexical analysis. You will extend the provided lexical analyzer to support more token types. The next section lists all new token types that you need to implement. C++ -- 2
$30-250 USD
En curso
Publicado hace casi 4 años
$30-250 USD
Pagado a la entrega
i want this project to be by 16th July . And it should be done g++ and tested in ubuntu.
1. Token Types
Modify the lexer to support the following 3 token types:
REALNUM = NUM DOT digit digit*
BASE08NUM = ((pdigit8 digit8*) + 0) (x) (08) BASE16NUM = ((pdigit16 digit16*) + 0) (x) (16)
Where
digit16 = 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + A + B + C + D + E + F pdigit16 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + A + B + C + D + E + F digit = 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
pdigit = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 digit8 = 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 pdigit8 = 1 + 2 + 3 + 4 + 5 + 6 + 7
Note that NUM and DOT are already defined in the lexer, but here are the regular expressions for the sake of completeness:
NUM = (pdigit digit*) + 0
DOT = '.'
Note that DOT is a single dot character, the quotes are used to avoid ambiguity.
The list of valid tokens including the existing tokens in the code would be as follows:
IF WHILE DO THEN PRINT PLUS MINUS DIV MULT EQUAL COLON COMMA
SEMICOLON LBRAC RBRAC LPAREN RPAREN NOTEQUAL GREATER LESS
LTEQ GTEQ DOT NUM ID
REALNUM BASE08NUM BASE16NUM
This list should be used to determine the token if the input matches more than one regular expression.
Follow these steps:
Download the [login to view URL] , lexer.h , [login to view URL] and inputbuf.h files accompanying this project description. Note that these files might be a little different than the code you've seen in class or
elsewhere.
Add your code to the files to support the token types listed in the
previous section.
Compile your code using GCC compiler in Ubuntu 19.04 or higher . You will need to use the g++ command to compile your code in a terminal window.
Note that you are required to compile and test your code in Ubuntu 19.04 or higher using the GCC compilers. You are free to use any IDE or text editor on any platform, however, using tools available in Ubuntu 19.04 g++ version 4.9 (or tools that you could install on Ububntu 19.04 could save time in the development/compile/test cycle. See next section for more details on how to compile using GCC.
Test your code to see if it passes the provided test cases. You will need to extract the test cases from the zip file and run the test script [login to view URL] . More details on this in the next section.
Submit your code in canvas before the deadline:
For this project you need to update [login to view URL] and lexer.h. The updates that you need to do in lexer.h are minimal and are already implemented in the submission website. So you do not need to upload the lexer.h file in CANVAS. But you still do need to update lexer.h if you want to compile locally.
3.1 Compiling Code with GCC
You should compile your programs with the GCC compilers which are available in g++ 4.9 in Ubuntu 19.04. The GCC is a collection of compilers for many programming languages. There are separate commands for compiling C and C++ programs:
Use gcc command to compile C programs
Use g++ to compile C++ programs
Here is an example of how to compile a simple C++ program:
$ g++ [login to view URL]
If the compilation is successful, gcc will generate an executable file named [login to view URL] in the same folder as the program. You can change the output file name by specifying the -o switch:
$ g++ [login to view URL] -o [login to view URL]
To enable all warning messages of the GCC compiler, use the -Wall
switch:
$ g++ -Wall [login to view URL] -o [login to view URL]
The same options can be used with gcc to compile C programs.
Compiling projects with multiple files
If your program is written in multiple source files that should be linked together, you can compile and link all files together with one command:
$ g++ [login to view URL] [login to view URL] [login to view URL]
Hi, hope you are doing well. I have been studying in Computer Science and have over 1000 hours on programming. I have written a lexical analysis for R language before. Please feel free to contact me. It would be my honor if you award me the project.