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

  Find the end-to-end delay on each of the three links

Note that the transmission rates are in Mbps and the link distances are in Km. Assume a packet length of 16000 bits. Give your answer in milliseconds.

  Write program for department of motor vehicles

Department of motor vehicles has finally decided to computerize its list of licensed drivers. Program you write must make use of existing file call Licenses with records of given form. Name, License Number

  Create a program to compute car-s miles-per-gallon

Create a program which ask's the user for number of miles driven and gallons of gas used. It must compute the car's miles-per-gallon and show the result on the screen.

  Creating printstream object using dos

Create a PrintStream object using dos and assign the resulting reference to ps, a PrintStream variable that has already been declared.

  Design application in visual basic.net 2005

Attached is a application created in Visual Basic.Net 2005

  Application to inputs five numbers given between a range

Write an application that inputs five numbers, each between 10 and 100, inclusive. As each number is read, display it only if it's not a duplicate of a number already read.

  Program ask user to enter starting amount in savings account

There is a Savings and a Checking account. Your program should begin by asking the user to enter the starting amount in the checking and savings accounts.

  Front end applications

How does a compiled binary executable store on the client computer?

  Create child processes

Create child processes

  Write application to retrieve the telephone number

Consider a program to enter codes of one to eight characters along with an associated telephone number and associated notes. A code can represent a person's name, a person's initials, a place, or anything.

  Create a file values.txt contains the data

Make sure your program is clear with no syntactical errors, correctly uses i/o syntax, correctly uses branching and looping syntax, that it contains functions with correct parameters and return values, that it correctly uses arrays, and that you p..

  Store normal for each face in array using technique

Use technique of the Astle text to store normal for each face in faceData array enable lighting and add point light source if the light is positioned at the origin

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