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

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

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