Write an interpreter for a minimal form of blue

Assignment Help Theory of Computation
Reference no: EM131137027

Interpreter Project

This project will be to write an interpreter for a minimal form of Blue. This minimal form of Blue has only 1 data type, integer, and the only identifiers are single letters. Blue is case sensitive.

The interpreter will parse a Blue program and build some intermediate data structures. These data structures will then be interpreted to execute the program. All tokens in this language are separated by white space. The parsing algorithm should detect any syntactical or semantic error. The first such error discovered should cause an appropriate error message to be printed, and then the interpreter should terminate. Run-time errors should also be detected with appropriate error messages being printed.

Grammar for the language

Parser

<program> → feature id do <statement_list> end id

<statement_list> → <statement> | <statement><statement_list>

<statement> → <if_statement> | <assignment_statement> | <loop_statement> | <print_statement> | empty_statement>

<if_statement> → if <boolean_expression> then <statement_list> else <statement_list> end if

<loop_statement> → loop <statement_list> exit on <boolean_expression><statement_list> end loop

<assignment_statement> -> id <assignment_operator><arithmetic_expression>

<empty_statement> ->

<print_statement> → print ( <arithmetic_expression> )

<boolean_expression> → <relative_op><arithmetic_expression><arithmetic_expression>

<relative_op> → le_operator | lt_operator | ge_operator | gt_operator | eq_operator | ne_operator

<arithmetic_expression> → <id> | <literal_integer> | <arithmetic_op><arithmetic_expression><arithmetic_expression>

<arithmetic_op> → add_operator | sub_operator | mul_operator | div_operator

Lexical Analyzer

id → letter

literal_integer → digit literal_integer | digit

assignment_operator→ :=

le_operator → <=

lt_operator → <

ge_operator → >=

gt_operator → >

eq_operator → =

ne_operator → <>

add_operator → +

sub_operator → -

mul_operator → *

div_operator → /

Reference no: EM131137027

Questions Cloud

Complete the case study etsy breaking down a business model : Read how to analyze a case and then complete the steps below: - The introduction: a brief of my understanding of the case - The environmental analysis Stating the problem.
Speed of light is a universal constant and has not changed : What will happen if all the clocks in the universe also start running at half the speed ?
Capabilities of the firm and evaluate based on value : Choose an organization and identify the resources or capabilities of the firm and evaluate based on value (v), rarity (r), imitability (i), and organizational aspects (O). Support your conclusions.
Mobile-enabled diabetes management devices : Prepare a Marketing Plan for Johnson & Johnson's mobile-enabled diabetes management devices, services and apps.The prototype iPhone application that would let users upload glucose readings from their connected blood glucose monitors directly to th..
Write an interpreter for a minimal form of blue : This project will be to write an interpreter for a minimal form of Blue. This minimal form of Blue has only 1 data type, integer, and the only identifiers are single letters. Blue is case sensitive
Risk for work-related musculoskeletal disorders : Identify a minimum of 3 job titles in the health care industry (e.g., nursing homes, hospitals, ambulatory clinics, surgical centers) whose workers are at risk for work-related musculoskeletal disorders.
Why is egoism form of moral relativism : Imagine that you are in a philosophy lecture class and the topic is philosophy known as stoicism, specifically on the idea that the wise person will act only to enjoy him or herself, and to get what he or she wants. Show you would organize your mater..
As a consultant to an international organisation : Background As a consultant to an international organisation, you are required to review the organisation's operations strategy and provide a detailed report on your findings.
Compare the pain relief effectiveness between the groups : What is the next test that is performed to determine specifically which of the four groups are different - what statistical test should be used?

Reviews

Write a Review

Theory of Computation Questions & Answers

  Write a vhdl module for a 6-bit accumulator with carry-in

Write a VHDL module for a 6-bit accumulator with carry-in (CI) and carry-out (CO). When Ad = o, the accumulator should hold its state. When Ad = 1, the accumulator should add the value of the data inputs D (plus CI) to the value already in the acc..

  Prove using the pumping lemma and closure properties

Prove using the pumping lemma and closure properties that the languages below are not regular. You can use the game argument provided in class.

  How do you think multimedia is changing our lives

How do you think multimedia is changing our lives ,Where does it penetrates our daily living and is it a good or bad effect and What do you think will develop in the near and in the far future?

  Visit any 2 websites that offer salary survey information

visit any 2 websites that offer salary survey information and compare your positionsalary with what is offered in those

  Task 1part onea research strategy is a plan of action that

task 1part onea research strategy is a plan of action that gives direction to your efforts enabling you to conduct your

  Compute the cost of one-to-all broadcast

Give an example of how increasing processor utilization increase inter processor communication and compute efficiency of adding n numbers on an n-processor hypercube.

  Construct a turing machine to compute the product

Construct a turing machine to compute the product x*y of any two positive integers x and y. Assume that the inputs x and y are represented in unary and are separated by a single 0.

  Give the transitions for a turing machine

Give the transitions for a turing machine that accepts the language given below.L = {AnBnCn : n>=1}

  Define predicate combinations

Define predicate combinations which find the number of combinations K of up to N numbers. Validate your predicate with the subsequent test:

  How many memory cells does a i-gigabyte memory contain

How many memory cells does a 4-Kbyte memory contain? How many memory cells does a I-gigabyte memory contain?

  1- when organization have a balance of both management and

1- when organization have a balance of both management and leadership and goals and challenges have been met how do we

  We have two versions of tn above depending on whether we

question we have two versions of tn above depending on whether we use a constant c or not. explain why the two versions

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