Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write program in c language using these rules un peu Yht There we re o d tegin ofert She right This - The Ang watent

image text in transcribed

image text in transcribed

image text in transcribed

write program in c language using these rules

un peu Yht There we re o d tegin ofert She right This - The Ang watent has a varithe len side and an athe the right side th a t the pris The n Aradament has the readed followed by a lot of variables within parentheses The Scenes An m ent has the write werd followed by a list of swiatles withis parentheses pared by comme the write statement with a semicolon Abrolan expression consists of all perand, a relatical operator, and a righe operand in that onder Anwend is either of an integer literal The relational operator Anielse utement has their word followed by a boolean expression within parenthesis followed by a sequence of statements within black followed by the else words towed by a sequence of statements within 1 block. The block has least one statement. The utements inside the block can be any of the five s e nt types An if-else statement may have no else part in that case, the if Matement has their word followed by a boolean expression within parenthesis ) followed by a sequence of statements within 1 block. A while statement has the while word followed by a boolean expression within parenthesis ) followed by a sequence of statements within block. The block has load one statement. The statements inside the block can be any of the five statement types. A comment begins with and ends at the end of the line. The comments are ignored by the scanner and the parser Determine all possible token types in the Micro language and deelde how to scan and extract each token type. Your scanner will be based on these token types. Submit the complete list of token types and indicate the total number of token types Write the complete set of EBNF grammar rules that describe the wyntax of the XMicro language. Your parser will be based on these grammar rules, Submit the complete set of EBNF grammar rules Your program has three components namely scanner, parser, and main. The whole program must be in one source file. The main program gives the user two options. LLLLLLLLLLLLL LLLLLLLLL C ECCE The first option is to scan the source code and write the sequence of tokens to another Quiput file. For this option, the program asks the user for the source code file and the output file. If there are lexical errors then errors are printed to the screen. The second option is to parse the source code. For this option, the program asks the user for the source code file. If there are no lexical errors and no syntax errors then a message indicating that parsing is successful is printed to the screen. Otherwise error messages are printed to the screen. Using option one, test your program with various XMicro programs to make sure that the scanner produces correct token sequence for valid programs and produces errors for invalid programs. Using option two, test your program with various XMicro programs to make sure that the parser recognizes valid programs and produces crrors for invalid programs The program must be written in C language. The source file must be named compilerc The program must compile under gcc compiler at the command line. The program must run at the command line. The program must be well documented with comments explaining all steps. desiguage and mod This programming assignment is about designing a scanner and a top down parser for a small scale language called XMicro. This language is an extension of the language discussed in the class. Your assignment is to extend and modify the scanner and the parser discussed in the class, so that the new scanner and the parser will scan and parse the XMicro language programs. The XMicro language has the following lexical and syntax rules A program begins with the word main followed by a sequence of statements within block. The block has at least one statement. There are five types of statements. They are assignment statement, read statement, write statement, if-else statement, and while statement An identifier consists of lower or upper case letters and digits. An identifier begins with a letter. The identifiers are case sensitive. The following identifiers are considered reserved words with predefined meaning: main, read, write, il, else, while. An arithmetic expression consists of variables, integer literals, plus operator +, minus operator multiplication operator division operator / left parenthesis and right parenthesis ). The usual arithmetic rules hold. The multiplication and division have precedence over addition and subtraction. The parentheses have higher precedence. The integer literals are positive integers or zero. An assignment statement has a variable on the left side and an arithmetic expression on the right side of the assignment operator. The assignment operator is The assignment statement ends with a semicolon. tie A read statement has the read word followed by a list of variables within parentheses separated by commas. The read statement ends with a semicolon. A write statement has the write word followed by a list of variables within parentheses separated by commas. The write statement ends with a semicolon. A boolean expression consists of a left operand, a relational operator, and a right operand in that order. An operand is either a variable or an integer literal. The relational operators are , = =, and != with their usual meanings. TecWH An if-else statement has the if word followed by a boolean expression within parenthesis peny wed by a sequence of statements within { } block followed by the else word 65 followed by a sequence of statements within ) block. The { } block has at least one statement. The statements inside the block can be any of the five statement types. An if-else statement may have no else part. In that case, the if statement has the if word followed by a boolean expression within parenthesis followed by a sequence of statements within { } block. A while statement has the while word followed by a boolean expression within parenthesis followed by a sequence of statements within 3 block. The block has at least one statement. The statements inside the block can be any of the five statement types. A comment begins with and ends at the end of the line. The comments are ignored by the scanner and the parser. Determine all possible token types in the XMicro language and decide how to scan and extract each token type. Your scanner will be based on these token types. Submit the complete list of token types and indicate the total number of token types. Write the complete set of EBNF grammar rules that describe the syntax of the XMicro language. Your parser will be based on these grammar rules. Submit the complete set of EBNF grammar rules. Your program has three components namely scanner, parser, and main. The whole program must be in one source file. The main program gives the user two options The first option is to scan the source code and write the sequence of tokens to another output file. For this option, the program asks the user for the source code file and the output file. If there are lexical errors then errors are printed to the screen. nu option is to parse the source code. For this option, the program asks the user for the source code file. If there are no lexical errors and no syntax errors then a message indicating that parsing is successful is printed to the screen. Otherwise error messages are printed to the screen. Using option one, test your program with various XMicro programs to make sure that the scanner produces correct token sequence for valid programs and produces errors for invalid programs. Using option two, test your program with various XMicro programs to make sure that the parser recognizes valid programs and produces errors for invalid programs. The program must be written in C language. The source file must be named compiler.c.. The program must compile under gcc compiler at the command line. The program must run at the command line. The program must be well documented with comments explaining all steps un peu Yht There we re o d tegin ofert She right This - The Ang watent has a varithe len side and an athe the right side th a t the pris The n Aradament has the readed followed by a lot of variables within parentheses The Scenes An m ent has the write werd followed by a list of swiatles withis parentheses pared by comme the write statement with a semicolon Abrolan expression consists of all perand, a relatical operator, and a righe operand in that onder Anwend is either of an integer literal The relational operator Anielse utement has their word followed by a boolean expression within parenthesis followed by a sequence of statements within black followed by the else words towed by a sequence of statements within 1 block. The block has least one statement. The utements inside the block can be any of the five s e nt types An if-else statement may have no else part in that case, the if Matement has their word followed by a boolean expression within parenthesis ) followed by a sequence of statements within 1 block. A while statement has the while word followed by a boolean expression within parenthesis ) followed by a sequence of statements within block. The block has load one statement. The statements inside the block can be any of the five statement types. A comment begins with and ends at the end of the line. The comments are ignored by the scanner and the parser Determine all possible token types in the Micro language and deelde how to scan and extract each token type. Your scanner will be based on these token types. Submit the complete list of token types and indicate the total number of token types Write the complete set of EBNF grammar rules that describe the wyntax of the XMicro language. Your parser will be based on these grammar rules, Submit the complete set of EBNF grammar rules Your program has three components namely scanner, parser, and main. The whole program must be in one source file. The main program gives the user two options. LLLLLLLLLLLLL LLLLLLLLL C ECCE The first option is to scan the source code and write the sequence of tokens to another Quiput file. For this option, the program asks the user for the source code file and the output file. If there are lexical errors then errors are printed to the screen. The second option is to parse the source code. For this option, the program asks the user for the source code file. If there are no lexical errors and no syntax errors then a message indicating that parsing is successful is printed to the screen. Otherwise error messages are printed to the screen. Using option one, test your program with various XMicro programs to make sure that the scanner produces correct token sequence for valid programs and produces errors for invalid programs. Using option two, test your program with various XMicro programs to make sure that the parser recognizes valid programs and produces crrors for invalid programs The program must be written in C language. The source file must be named compilerc The program must compile under gcc compiler at the command line. The program must run at the command line. The program must be well documented with comments explaining all steps. desiguage and mod This programming assignment is about designing a scanner and a top down parser for a small scale language called XMicro. This language is an extension of the language discussed in the class. Your assignment is to extend and modify the scanner and the parser discussed in the class, so that the new scanner and the parser will scan and parse the XMicro language programs. The XMicro language has the following lexical and syntax rules A program begins with the word main followed by a sequence of statements within block. The block has at least one statement. There are five types of statements. They are assignment statement, read statement, write statement, if-else statement, and while statement An identifier consists of lower or upper case letters and digits. An identifier begins with a letter. The identifiers are case sensitive. The following identifiers are considered reserved words with predefined meaning: main, read, write, il, else, while. An arithmetic expression consists of variables, integer literals, plus operator +, minus operator multiplication operator division operator / left parenthesis and right parenthesis ). The usual arithmetic rules hold. The multiplication and division have precedence over addition and subtraction. The parentheses have higher precedence. The integer literals are positive integers or zero. An assignment statement has a variable on the left side and an arithmetic expression on the right side of the assignment operator. The assignment operator is The assignment statement ends with a semicolon. tie A read statement has the read word followed by a list of variables within parentheses separated by commas. The read statement ends with a semicolon. A write statement has the write word followed by a list of variables within parentheses separated by commas. The write statement ends with a semicolon. A boolean expression consists of a left operand, a relational operator, and a right operand in that order. An operand is either a variable or an integer literal. The relational operators are , = =, and != with their usual meanings. TecWH An if-else statement has the if word followed by a boolean expression within parenthesis peny wed by a sequence of statements within { } block followed by the else word 65 followed by a sequence of statements within ) block. The { } block has at least one statement. The statements inside the block can be any of the five statement types. An if-else statement may have no else part. In that case, the if statement has the if word followed by a boolean expression within parenthesis followed by a sequence of statements within { } block. A while statement has the while word followed by a boolean expression within parenthesis followed by a sequence of statements within 3 block. The block has at least one statement. The statements inside the block can be any of the five statement types. A comment begins with and ends at the end of the line. The comments are ignored by the scanner and the parser. Determine all possible token types in the XMicro language and decide how to scan and extract each token type. Your scanner will be based on these token types. Submit the complete list of token types and indicate the total number of token types. Write the complete set of EBNF grammar rules that describe the syntax of the XMicro language. Your parser will be based on these grammar rules. Submit the complete set of EBNF grammar rules. Your program has three components namely scanner, parser, and main. The whole program must be in one source file. The main program gives the user two options The first option is to scan the source code and write the sequence of tokens to another output file. For this option, the program asks the user for the source code file and the output file. If there are lexical errors then errors are printed to the screen. nu option is to parse the source code. For this option, the program asks the user for the source code file. If there are no lexical errors and no syntax errors then a message indicating that parsing is successful is printed to the screen. Otherwise error messages are printed to the screen. Using option one, test your program with various XMicro programs to make sure that the scanner produces correct token sequence for valid programs and produces errors for invalid programs. Using option two, test your program with various XMicro programs to make sure that the parser recognizes valid programs and produces errors for invalid programs. The program must be written in C language. The source file must be named compiler.c.. The program must compile under gcc compiler at the command line. The program must run at the command line. The program must be well documented with comments explaining all steps

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions