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

  Java application to display multiple choice questions

Write down the application which displays series of TEN(10) multiple choice questions: questions must cover all the Java. Each question must have four possible answers and only one answer must be correct.

  Solution for the problem and mention algorithms

Explain the purpose of the program as detail as possible and develop a solution for the problem and mention algorithms to be used and list data structures to be used in solution.

  Write an interface for a bagadt that implements iterable

Write an interface for a BagADT that implements the Iterable interface. Include javadoc comments that will generate specifications for the BagADT so that someone who wants to implement this interface will know what each method does.

  Java program to ask user to enter favorite color

Write a Java program to ask the user to enter favorite color, a favorite food, favorite animal, and first name of a friend or relative.

  A remote web-based file storage application

Develop a web-based application. The server-side part of the application must be developed using Java Servlets (possibly including JSP). The development of the client (browser) side will typically be a combination of HTML and Javascript.

  Write a complete java program assuming that the variables gp

Write a complete java program Assuming that the variables gpa, deanList and studentName have been declared, you should read in the studentName and gpa from keyboard. Write an if statement that adds 1 to deansList and prints studentName to the standar..

  The string class and/or the stringbuffer class in java

Create a simple Java application that uses the String class and/or the StringBuffer class and at least 4 of the class methods. Show the code, demonstrate it works properly and describe what it is doing.

  Writing a java program that provides simple statistics

You will be writing a Java program that provides simple statistics about the input data. The method stubs are given below. This assignment will give you experience with methods

  Implement a client program

Implement a client program with a main method to demonstrate the evolution of the sales tax rates in the 50 US states over the last 10 years. Declare a two-dimensional array of values representing the sales tax rates. Dimension 1 represents the st..

  Specify, design and implement a class

Specify, design and implement a class that can be used to hold information about a musical note. Test it with an appropriate driver program.

  Carry out additions and subtraction

You are to design a Java application to carry out additions and subtractions for numbers of any length. A number is represented as an object which includes a sign and two strings for the whole and decimal parts of the number.

  The frantic pipe layer game1 the completed gamehere is what

the frantic pipe layer game.1 the completed gamehere is what the user interface should look like when completedyou must

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