Write a parser for a programming language

Assignment Help Other Subject
Reference no: EM133169988

CIS524 Project

Requirements:
• Write in two languages
o Language 1: C or C++
o Language 2: Java
o Language 3: Python
• Must be able to compile in a machine in our department (spirit, bach, etc)
• Submit to both CSU Blackboard and grail.eecs.csuohio.edu CIS524
• Each person in a group must submit; otherwise treated as "NO SUBMISSION" (0 points)

Project Description:

Write a parser for a programming language that accepts the following EBNF using the method in textbook Chapters 3 and 4

<Program1> -> (<VarDefinition> | <AssignmentStatement> | <ForStatment>) {(<VarDefinition> | <AssignmentStatement> | <ForStatment>) }
<varDefinition> -> var <varName>;
<varName> -> (a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z){ (0|1|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z) }
<AssignmentStatement> -><varname> = <ExpressionStatement>;
<ExpressionStatement> -> (<varname> | <constant>) { + (<varname> | <constant>) };
<constant> -> (0|1) {(0|1)}
<ForStatement> -> for "(" var <AssignmentStatement><ConditionStatement><IncreasementStatement> ")" "{"
{<AssignmentStatement>}
"}"
<ConditionStatement> -><VarName>(">" | "<" )<ExpressionStatement>
<IncreasementStatement> -><varName>++;
(1) var <varname>;
<varname> -> (a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z){0|1|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z}

<varname> begins with a letter in a-z, remaining can be a-z, 0-1
var is the keyword.

Example:
var abcd001;

(2) assignment statements

<varname> = (<varname> | <constant>) { + (<varname> | <constant>) };

<constant> is an integer number in binary format, such as 000, 1000, 011000011, 111001000

example
var1 = var2 + var3 + 110 + 011 + var5;

(3) for statements
example
for (var var1=001; var1 < 11100; var1++){
myvar = myvar + var1;
}

Given a text file, if the text file follows the above format, your compiler compiles the text file successfully, and outputs
"Compilation succeeded."

Eg. run your compiler as ./MyCompiler successful-compilation-text-case-1.txt
the successful-compilation-text-case-1.txt is written as follows:

var counter;
counter = 10;
for (var index=0; index < 11100; index++){
counter = counter + index;
}

The output will be "Compilation succeeded."

Given a text file, if the text file fails the above grammar, it will point out where the exact position where the grammar is wrong.
If there are multiple places grammar is wrong, then the first position where grammar is wrong will be pointed.
It will point to the exact line and the exact column position from the line that is incorrect.

Eg. run your compiler as ./MyCompiler unsuccessful-compilation-text-case-1.txt
the unsuccessful-compilation-text-case-1.txt is written as follows:

var counter;
counter = 93
for (var index=0; index < 11100; index++){
counter = counter index;
}

Your program will output

Line 2, column 11, incorrect grammar
Compilation failed.

Eg. run your compiler as ./MyCompiler unsuccessful-compilation-text-case-2.txt
the unsuccessful-compilation-text-case-2.txt is written as follows:

var counter;
counter = 11;
for (var index=0; index 11100; index++){
counter = counter index;
}

Your program will output

Line 3, column 25, incorrect grammar
Compilation failed.

Eg. run your compiler as ./MyCompiler unsuccessful-compilation-text-case-3.txt
the unsuccessful-compilation-text-case-3.txt is written as follows:

var counter;
counter = 11;
for (var index=0; index < 11100; index++){
counter = counter index;
}

Your program will output

Line 4, column 23, incorrect grammar
Compilation failed.

Attachment:- Group_project.rar

Verified Expert

The assignment required use of codes that were used in the analysis and programming of the programme in the database . The use of parser programming language was also applied regarding the use of EBNF method . In this regard the application of both Java and C++ was necessarily in structuring and coding the assignment . In this case the assignment involved stage by stage of programming from the data input to data output.

Reference no: EM133169988

Questions Cloud

Prepare general journal entries to record transactions : Prepare the general journal entries required to record the transactions that occurred during 2022. Assume depreciation has been recorded up to 31 December 2021
Discuss three major religious values : Discuss three major religious values (such as Islam, Christianity and Judaism ) impact relate to the differences in accounting systems and reporting
Prepare the journal entry for the june : The market rate on the issue date was 8%, which priced the bonds at $46,602.42. Prepare the journal entry for the June 30, 2020 interest payment
Prepare the journal entries for hungry joe : Prepare the journal entries for Hungry Joe's for June 14, Hungry Joe's June 30 year end, and the repayment of the loan
Write a parser for a programming language : Write a parser for a programming language that accepts the following EBNF using the method in textbook Chapters
Determine the amount that should be entered on profit line : These partially completed Income Statement columns from a 10-column work sheet. determine the amount that should be entered on profit line
How would these tax consequences differ : How would these tax consequences differ from the information included in Latkin's GAAP based financial statements
Rooted in the literature : Is the topic attainable for a first-time dissertation student? Is the problem rooted in the literature?
Baseline security requirements : What are baseline security requirements that should be applied to the design and implementation of applications, databases, systems, network infrastructure,

Reviews

Write a Review

Other Subject Questions & Answers

  Incorporate feedback and suggestions

Write a 1,750- to 2,850-word research paper and prepare an accompanying presentation that meets the following requirements: • Incorporate feedback and suggestions from Part I.

  What are genotypes and phenotypes

What are genotypes and phenotypes? How do genotypes and phenotypes relate to the concepts of dominant and recessive genes?

  List out various supporting claims based on bubbled ideas

What order makes the best sense for your various supporting claims? What information would readers appreciate earlier rather than later in your paper?

  Positive freedom is the ability to do what one should do

positive freedom is the ability to do what one should do. negative freedom is the ability to do what one should not

  Describe the mode of entry and its effectiveness

Explain in specific detail which international strategy the organization has adopted and the likely reasons why it used this strategy. Describe the mode of entry and its effectiveness

  Discuss the differences between tariffs and quotas

Discuss the differences between tariffs and quotas. How are they the same, and how ae they different? How does international trade alter the distribution.

  Pollutants can harm ecosystem function and may also harm

pollutants can harm ecosystem function and may also harm human health.you will write an apa-style research paper about

  What is it that ethics aims to explain

Identify the basic themes, topics, and concepts that make up the discipline of ethics. What are the themes or ideas that unite the different ethical theories?

  Why is the gather requirements activity so important

What requirements would you need to know about? For each requirement, who would you need to talk to get detailed clarification?

  Find a test to assess and intelligence

Find a test to assess, intelligence or education, find a similar alternative test for administration with an individual who may be blind, deaf, or nonverbal.

  Evaluate one of the neurotransmitters

Evaluate one of the neurotransmitters covered in this week's readings. Explain the role it plays in modulating responses to a drug of abuse.

  How can an organization benefit from the of this tool

You've provided some good information about benchmarking. With respect to strategic planning, how can an organization benefit from the use of this tool to benefit its continuous improvement process?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd