Find Jobs
Hire Freelancers

syntactic analyzer for a small language called SL

$30-70 USD

Peruutettu
Julkaistu yli 17 vuotta sitten

$30-70 USD

Maksettu toimituksen yhteydessä
see deliverables ## Deliverables ** ** CS 4303 Programming Language Concepts Programming Assignment One The **purpose** of this programming assignment is to write a syntactic analyzer for a small language called SL. The grammar of SL, which defines a C-like nested block, is given by the following BNF definitions. <block> ::= <label> ‘:’ ‘{‘ <declaration-list> <cmd-sequence> ‘}’ <label> ::= L | M | N <declaration-list> ::= <declaration> <declaration-list> | <empty> <declaration> ::= <type> <var> ’;’ | <type> <var> ’=’ <number> ’;’ <type> ::= int | float <var> ::= A | B | C | D | E <cmd-sequence> ::= <cmd> <cmd-sequence> | <empty> <cmd> ::= <assignment> | <if-cmd> | <while-cmd> | <block> <assignment> ::= <var> ‘=’ <expr> ‘;’ <if-cmd> ::= if <cond> <cmd> | if <cond> <cmd> else <cmd> <while-cmd> ::= while <cond> <cmd> <cond> ::= ‘(‘<var> <comp> <var>’)’ <comp> ::= == | != <expr> ::= <expr> * <atom> | <expr> + <atom> | <atom> <atom> ::= <var> | <number> <number> ::= <integer> | <float> <integer> ::= <digit> <integer> | <digit> <digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 <float> ::= <integer> ‘.’ <integer> Your program will read a program written in SL and produce a listing (with line numbers) and a list of syntax errors (if any). Your program does not produce any parse trees or symbol tables. Note that SL is case sensitive. To receive full credit, write the program with good logic, well indented and well documented. Turn in a copy of your program, copy of the data files used (besides the files given with this assignment) and a copy of the output produced and a diskette containing all the files by the [due date][1]. Test your program with the data files enclosed in this assignment, which are named **[[login to view URL]][2], [[login to view URL]][3], [[login to view URL]][4], [[login to view URL]][5], [[login to view URL]][6], [[login to view URL]][7], [[login to view URL]][8], [[login to view URL]][9], [[login to view URL]][10], [[login to view URL]][11]**. Sample output can be found in [[login to view URL]][12], and [[login to view URL]][13]. Note: **Your program must read the input from a file, one input program one file**. **On the project due date (check the course [syllabus][1]), turn in a disk containing the source code and the input files; and a print-out of your source code and the output of your program.** *_Hints_*: The easiest way to do this assignment is the following: Step 1: Remove left recursion in the grammar. The above grammar contains only one left recursive production: <expr> ::= <expr> * <atom> | <expr> + <atom> | <atom> It can be rewritten into EBNF (**figure out what it is**.) and then you write the recursive descent recognizer for the EBNF. Step 2: Write a recursive descent parser for each of the productions. Recursive descent parser is described in textbook section 4.6. In this step, however, we should consider how to separate lexical analysis from syntactic analysis. Without a clear cut-off between what lexical analyzer (scanner) and what syntactic analyzer (parser) does, the design of the parser can be easily messed up. For example, the recursive descent recognizer of <declaration> may end up with a very complicated control structure to deal with the problem in reading and recognizing key words "int" and "float". To make the design of the recursive descent recognizers clear, function "GetToken" should recognize all tokens that are used by the language. With the use of a well-designed "GetToken", the recursive descent recognizers need only analyze syntactic structures. For language SL, the tokens used are in the following (separated by comas): :, {, }, L, M, N, ;, =, int, float, A, B, C, D, E, if, else, while, (, ), ==, !=, *, +, <number> where <number>s are regarded as a token although they are defined by the grammar. This will ease the design of the parser. The best way for designing the "GetToken" function is extending the function we have designed in Lab 1 to make it work for the new set of tokens. As an option, an example code for "GetToken" can be found in file [GetToken.c][14] . "GetToken" assumes C string "Token" is defined globally. "in" is the global input stream open for the input file. Function "GetToken" reads in input programs line by line (The maximum length of a line is defined by global constant "MAX_LINE_LEN"), stores the input line in a global buffer called "line", and extract tokens from "line" buffer. Whenever it reaches the end of line, and the read pointer of the file does not reach the end of the file, "GetToken" reads in the next line; otherwise, does nothing. We do not consider error recovery in this project. Whenever a syntactic error is found, your parser should just terminate parsing, printing an error message and stop. The error message printed out should indicate what kind of error is encountered, such as "illegal variable name", "missing =", "unrecognizable statement", etc.. Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables): a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment. b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request. 3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement). ## Platform all the file thats needed for the project is in the attached zip file test files out_put files GetToken.c
Projektin tunnus (ID): 2824086

Tietoa projektista

9 ehdotukset
Etäprojekti
Aktiivinen 17 vuotta sitten

Haluatko ansaita rahaa?

Freelancerin tarjouskilpailun edut

Aseta budjettisi ja aikataulu
Saa maksu työstäsi
Kuvaile ehdotustasi
Rekisteröinti ja töihin tarjoaminen on ilmaista
9 freelancerit tarjoavat keskimäärin $45 USD tätä projektia
Käyttäjän avatar
See private message.
$25,50 USD 10 päivässä
4,9 (435 arvostelua)
7,4
7,4
Käyttäjän avatar
See private message.
$55,25 USD 10 päivässä
5,0 (113 arvostelua)
6,7
6,7
Käyttäjän avatar
See private message.
$55,25 USD 10 päivässä
5,0 (158 arvostelua)
6,0
6,0
Käyttäjän avatar
See private message.
$51 USD 10 päivässä
4,9 (51 arvostelua)
4,2
4,2
Käyttäjän avatar
See private message.
$42,50 USD 10 päivässä
5,0 (7 arvostelua)
3,2
3,2
Käyttäjän avatar
See private message.
$42,50 USD 10 päivässä
5,0 (5 arvostelua)
1,7
1,7
Käyttäjän avatar
See private message.
$55,25 USD 10 päivässä
5,0 (5 arvostelua)
1,8
1,8
Käyttäjän avatar
See private message.
$25,50 USD 10 päivässä
5,0 (2 arvostelua)
0,0
0,0
Käyttäjän avatar
See private message.
$55,25 USD 10 päivässä
0,0 (0 arvostelua)
0,0
0,0

Tietoja asiakkaasta

Maan UNITED STATES lippu
Charlotte, United States
5,0
5
Liittynyt lokak. 3, 2006

Asiakkaan vahvistus

Muita töitä tältä asiakkaalta

8086 Assembly Language
$30-40 USD
Kiitos! Olemme lähettäneet sinulle sähköpostitse linkin, jolla voit lunastaa ilmaisen krediittisi.
Jotain meni pieleen lähetettäessä sähköpostiasi. Yritä uudelleen.
Rekisteröitynyttä käyttäjää Ilmoitettua työtä yhteensä
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Ladataan esikatselua
Lupa myönnetty Geolocation.
Kirjautumisistuntosi on vanhentunut ja sinut on kirjattu ulos. Kirjaudu uudelleen sisään.