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

  Identify at least two advantages to using oop

Use the Internet to research the advantages, features, and common examples of OOP and EDP. Note: You may use the Association for Computing Machinery (ACM) Digital Library to support research on the above topics.

  Modify the dynamic programming algorithm

How would you modify the dynamic programming algorithm for the coin collecting problem if some cells on the board are inaccessible for the robot?

  Determine proper lower bound and upper bound on ?nal value

Determine the proper lower bound and upper bound on the ?nal value of the shared variable tally output by this concurrent program.

  The design and testing the design of learning environments

HCI projects will gravitate on the design and testing the design of learning environments. Design or improvement of a computer application to support; promote learning, identifying new means of using technology for fostering and assessing learning..

  Specific changes made for different countries-sites directed

Why were these specific changes made for different countries at whom the sites were directed? Is there anything else you would consider changing.

  Write a shell script to read students first names

Write a shell script that reads 5 students' first names, last names and grades and then it calculates the average, maximum and minimum grade.

  Assignment on the two-dimensional array sales

Use a two-dimensional array to solve the following problem: A company has four salespeople (1 to 4) who sell five different products (1 to 5). Once a day, each salesperson passesin a slip for each type of product sold. Each slip contains the follo..

  Write program to compute integer part of quotient

Write program segments that accomplish each of the following: Calculate the integer part of the quotient when integer a is divided by integer b.

  Create effective navigation for the application or site

Use any familiar web, JavaTM, .NET, or database development tool to design, develop, and create the application or site. Create effective navigation for the application or site

  Formula translation

Write a c code that will evaluate the roots of a quadratic equation

  Use that function to output each line of the countdown

Write code to create a web page that uses a JavaScript program to output a NASA style count down:

  Create application to enter five-digit credit card number

Create an application that allows the user to enter a five-digit credit card number; assume that the fifth digit is the check digit.

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