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

  Finite-state machine design

Create a finite-state machine design to turn your FPGA development board into a simple programmable music box.

  Redundant sequence identi cation

Redundant sequence identi cation

  Compute a shortest superstring

Dynamic programming algorithm to compute a shortest superstring.

  Propositional and predicate logic

Write down a structural induction principle for the PlayTree free type

  Design a syntactic analyzer

Design a syntactic analyzer for the language specified by the grammar

  Design unambiguous grammar to parse expressions

Write a program would read two numbers and then print all numbers between the first and the second, inclusive. Design unambiguous grammar to parse expressions

  Consider a logic function with three outputs

Consider a logic function with three outputs,  A ,  B , and  C , and three inputs,  D ,  E , and  F . The function is defined as follows:  A  is true if at least one input is true,  B  is true

  Considering a single programmed operating system

Considering a single programmed operating system, what is the minimal total time required to complete executions of the two processes? You should explain your answer with a diagram.

  How to construct an nfa

Give a construction that assumes you are given a DFA for L and show how to construct an NFA (with or without ε-moves) to recognize sort(L).

  Equivalence classes to construct minimal dfa for language

How many equivalence classes does this relation have and what are they? Use these equivalence classes to construct the minimal DFA for the language.

  Impact of moore-s law on data center costs

Discuss the impact of Moore's law on data center costs on such things as servers and communications equipment. List at least 3 steps or recommendations your data center can take to offset some or all of the effect of Moore's law.

  Problem encountered in statements in predicate logic

How the problem would be encountered in attempting to represent the following statements in Predicate logic. it should be possible to: John only likes to see French movies.

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