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

  What activities can a leader use to help get the team to

what activities can a leader use to help get the team to buy-in to the vision so that it becomes a shared

  Design a syntactic analyzer

Design a syntactic analyzer for the language specified by the grammar

  Succession planning is an important od intervention and

succession planning is an important od intervention and business sector succession planning-sometimes called workforce

  1 produce a report of up to 500 words on the topic talent

1. produce a report of up to 500 words on the topic talent planning in operation. nbspnbspnbspnbsp please ensure that

  Design jflap truing machine takes input a tape

Design in JFLAP a Truing machine that takes as input a tape containing a series of n 1s, Where n >= 0, terminated by an = sign.

  A music store owner wants to have enough

A music store owner wants to have enough of the hottest CDs in stock so people who come to buy a particular CD won't be disappointed - and the store won't lose the profit. CDs that are not sold within a certain length of time go onto the sale tabl..

  Construct a dfa that recognizes languages

Construct a DFA that recognizes each of the following languages. Unless otherwise noted we are assuming that ω ∈ {0,1}*. (A drawing of a state diagram is sufficient.)

  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.

  1centred on the significance and relevance of ramps to

1centred on the significance and relevance of ramps to canadian organizations why is ramps important? and why is it

  Find the square roots of the matrix

Compute Ak and eAt using the Cayley - Hamilton theorem. Find the square roots of the matrix, i.e., find all matrices B such that B2 = A using the Cayley - Hamilton theorem method.

  Write the predicate singlechild

Write the predicate singleChild(Name) which finds the name of single children - For this problem single children means no other child has the same father and mother.

  Rahman s a 2006 lsquoattitudes of malaysian teachers toward

rahman s. a. 2006 lsquoattitudes of malaysian teachers toward a performance-appraisal system journal of applied social

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