Scanning and parsingimplement the lexical and syntactic

Assignment Help JAVA Programming
Reference no: EM13346893

Scanning and Parsing

Implement the lexical and syntactic analysis of Minifun programming language. The scanner splits up the input into catches and tokens lexical errors (inputs that cannot form valid tokens). The parser checks that the input list of tokens conforms to a syntax specified using a context-free grammar. It is convenient to convert the initial parse tree, which follows the context-free grammar used for parsing, into a simpler Abstract Syntax Tree. It is recommended that your design follow the above stages, though it is not required, as long as you somehow implement the lexical and syntactic specification of Minifun.

Minifun Language

Minifun is a functional programming language and it is a subset of Scheme language (you can browse to learn about Scheme). It includes variables, functions, integers and basic integer arithmetic, booleans, relacional functions, "cond" conditional statement, and lists. It doesn't include strings, real numbers nor structures.

The Minifun grammar

1. <prog> ::= <s-exp> | <s-expr> <prog>
2. <s-exp> ::= <def> | <exp>
3. <def> ::= (define (<var> <var> ... <var>) <exp>) | (define <var> <exp>)
4. <exp> ::= <var>
| <con>
| (<prm> <exp> ... <exp>)
| (<var> <exp> ... <exp>)
| (cond (<exp> <exp>) ... (<exp> <exp>))
| (cond (<exp> <exp>) ... (else <exp>))
5. <var> ::= See definition below
6. <con> ::= See definition below
7. <prm> ::= + | - | * | / | = | < | > | <= | >=

The category of variables <var>, which are the names of functions and values, follow basically the same spelling rules. They can be made up of upper-case and lower-case letters (yes, case matters!), hyphens and underscores. They cannot contain spaces. Nor can they contain parentheses, curly braces, square brackets, apostrophes, commas, or quotation marks, as these all have special meanings in minifun.

The nonterminal <con> introduces constants: boolean and numeric constants. A number (integer) is a sequence of as many digits (0-9) as you wish. A boolean constant can be either #t (true value) or #f (false value).

A space is necessary to separate one name or number or operation <prm> (see above) from another. They are allowed, but not required, before and after parentheses, square brackets, and curly braces.

For the classification of minifun sentences, we also need three keywords: define, cond, and else. These keywords have no meaning. No keyword may be used as a variable. You must hand in to Blackboard a .zip archive containing your source code. Your main program must be called mfunc. When run with a single argument, a filename, mfunc should process the given file, produce appropriate diagnostic messages on standard error, and exit with one of the following return codes:

0: the input file is lexically/syntactically valid mimp

-1: the input file is not lexically/syntactically valid mimp

Reference no: EM13346893

Questions Cloud

Analysis design and development of a small software system : analysis design and development of a small software system. produce an executable software solution to the
Allelectronics caries 1000 products p1 p1000 consider : allelectronics caries 1000 products p1 . p1000. consider customers ada bob and cathy such that ada and bob purchase
Theory of interest- non-annual interest rates and : theory of interest- non-annual interest rates and annuitiesfind the annual effective rate of interest equivalent to a
Describe concepts of database-orientated programming : describe concepts of database-orientated programming language plsql as well as of data analysis techniques for
Scanning and parsingimplement the lexical and syntactic : scanning and parsingimplement the lexical and syntactic analysis of minifun programming language. the scanner splits up
Question 1which of the following statements is true for a : question 1which of the following statements is true for a trapdoor function f?answer a.the function f can be computed
1 object oriented programming class hierarchies : 1. object oriented programming class hierarchies inheritance and virtual functions in this part of the assignment you
Describe and evaluate this type of internal audit what : describe and evaluate this type of internal audit. what types of organisation would it be most useful for?required1
Build the gui layout of the gamecreate a class called : build the gui layout of the gamecreate a class called pipegameapp.java which will be the main game user interface. the

Reviews

Write a Review

JAVA Programming Questions & Answers

  What is relationship between hashing and digital signatures

The security advantages of using two-factor authentication, such as the integrated fingerprint reader in the more recent iPhone models, particularly to support internet services (such as online banking)

  Print the contents of the array

Prepare a second loop that prints the contents of the array

  Palindrome by doing character replacement

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement.

  Write a java program that finds the temperature

Write a JAVA program that finds the temperature that is the same in both Celsius and Fahrenheit

  Create a class in java to enable its object to be persiste

How do you create a class in Java to enable its object to be persistent? What are Java data streams and how are they used to facilitate storage and retrieval of persistent objects?

  Design a program that asks the user to enter a series of 20

Number Analysis Program: Design a program that asks the user to enter a series of 20 numbers

  Tese 14 questions covers java class array link list

these 14 questions covers java class array link list generic class please read carfullynbspnbsp1. suppose we have a

  Using a link list implementation

Using a link list implementation, simulate the war car game. The program should read an input of several line of card values and output the winner and the number of rounds it takes.

  Java program for line item application

This exercise explains you the process of testing and enhancing Line Item application. Open LineItemApp, Validator, Product, LineItem, and ProductDB classes that are in the c:java1.6ch06LineItem directory and review this code.

  Write a java program that will read a sequence of names

Write a java program that will read a sequence of names (first name followed by last name, separated by at least one space) from a text file and will 1) remove all duplicate names and 2) write the names (last name followed by a comma, followed by one..

  Compute the temperature in centigrade

Compute the temperature in Centigrade - Display the temperatures in both Centrigrade and Fahrenheit with appropriate labels, using the + operator to concatenate the labels with the variables

  Build a simple text-based adventure game

Build a simple text-based adventure game. You can and probably should use our Missed Connections example as the foundation for your game.

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