Construct a finite state machine m that accepts

Assignment Help Programming Languages
Reference no: EM131004873

Programming language design Problem

1. Design a naïve and simple programming language which consists of the following primitive five statement types as program constructs, beside the declaration statements: These program constructs are powerful enough to write almost every algorithm for finding a solution of any given problem. [Throughout the rest of this semester, we will continue to expand this primitive programming language by adding other features, such as some data types, function or recursive call.]

 

Declaration statements; (e.g., int x; float x; int array A[1..n-1]; float array A[1..n-1]; char x; )

read and write statement;

assignment statement;

if-then-else statement and if-then statement; and

while-do statement;

Composition statement; i.e., statement; statement(s);

 

For example, I can use these program constructs to input (such as read) and output (such as write) any given integers, find the sum of these given integers, and output their total.

 

program sum

begin

int x, sum;

sum := 0;

while (not end of file) do

{read x;

write x;

sum := sum + x;

}

write sum;

end

 

Using these program constructs I can write binary search algorithm, mergeSort algorithm, ...

You are free to create the descriptive details of these statements, which allow define a set of grammar rules (also called syntax rules) for these statements. You also can add other features. However, you are advise to make it as simple as possible.

 

In addition to other reserved words, you can use begin and end as reserved words and {

Statements } for defining a block-structured language. For your reference, some of the grammar rules are given as follows: The notation < ... > is used to denote nonterminal symbols. Otherwise, they are terminal symbols (e.g., the entire program sum ... end are terminal symbols, consisting tokens/identifiers/variables, constant, assignment operators, relation operator such as not, and <, and many reserved words).

 

<Program> => begin <Statements> end

<Statements> => <Statement> | <Statement> <Statements>

| { <Statement> <Statements> }

<Statement> => <assignmentStatment> | <if-then-elseStatment>

| <while-doStatement> | { Statements }

<while-doStatement> => while (<bExpression>) do <Statements> ;

<if-then-elseStatment> => if (<bExpression> ) then <Statements> ;

| if (<BExpression> ) then <Statements> else <Statements> ;

<assignmentStatement> => <variable> : = <aExpression>;

 

<aExpression> => <term> | <aExpression> + <term>

<term> => <factor> | <term> * <factor>

<factor> => <constant> | <variable> | ( <aExpression> )

<variable> => <identifier> | <identifier> <variable>

<identifier> => A|B| ...|X| Y | Z | a | b | ....| x | y | z | 0 | 1 | 2 | ... | 8 | 9 |

<constant> => <digit> | <digit> <constant>

<digit> => 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

 

Note that { ... } for declaring block of statements, which could be nested, such as

begin ... { ... { .... } ... { ... { .... } ...} .... } end.

 

These grammar rules are not complete. You are free to develop a complete set of grammar rules for these statements. You are advised to expand the following grammar rules to cover most of the basic properties/features for the statements for developing a program for any given problem.

2. Construct a finite state machine M that accepts these variables, constants, assignment operators and others, as well as all the reserved words for this primitive programming language that you are defined in Problem 1.

3. Construct a pushdown automata N for accepting or rejecting any given program which is written based on these program constructs, developed in Problem 1.

Reference no: EM131004873

Questions Cloud

About the production lines : A company will need $100,000 in five year's time to replace one of its production lines. Assuming the company can earn 7% per year compound interest on its savings, how much should the company be saving at the end of each year for the next five years..
Best describes tariffs : Which option best describes tariffs in Chile.
Informed critic of the affordable care act : You now know everything you need to know to be an informed critic of the Affordable Care Act. Based on all that you have learned, how does the Act measure up to our three goals of 1) increasing quality of care, 2) increasing access to care and 3) kee..
Use the watchdog in its default position : Use the watchdog in its default position (must be petted in less than 32 ms). Generate a 275 Hz, 50% duty cycle on P9.7. Use a timer with the SMCLK.
Construct a finite state machine m that accepts : Construct a finite state machine M that accepts these variables, constants, assignment operators and others, as well as all the reserved words for this primitive programming language that you are defined in Problem 1.
What recommendation would you make about purchasing : Based on the future value of the company that you calculated, and being mindful of the need to effectively balance portfolio risk with return, what recommendation would you make about purchasing the company as an investment at that price? Be sure to ..
Accounting for economic growth econ 311 : Accounting for Economic Growth, ECON 311 Assignment 3, Calculate the growth rates of real GDP per worker and capital per worker for each time period. What is the average growth rate and standard deviation for both?
Compute the financial ratios for both firms : Compute the financial ratios for both firms for the most recent year, and evaluate the relative performance of the two firms in the following areas:
Complete factorial analysis of variance in smart alex : Complete factorial analysis of variance in Smart Alex's Task #1 on p. 541, using the Fugazi.sav data set from the Field text. You can follow the steps outlined on pp. 520–525 as a guide.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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