Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- Implementation Task:- e We are going to implement a tokenizer recognizing strings which are well-defined representations for real values using the functional programming language

image text in transcribed

- Implementation Task:- e We are going to implement a tokenizer recognizing strings which are well-defined representations for real values using the functional programming language Scheme in the DrRacket IDE. We consider the following three formats to define a real value: A. Integer numbers. A valid string should only contain digits except the signs "+" and "-", such that "+" is neglectable if the number is nonnegative. It is allowed to have zeros at the beginning of the string. B. Fixed-point numbers. A valid string should have the integer part and the fractional part. The sign "+" is optional if the number is nonnegative. C. Scientific notations. For example, the number 4321.768 can be represented by the scientific notation 4.321768e3, or 4.321768e+3. The number 0.000012 can be represented by le-5. Therefore a scientific notation has 3 sections, the first section is a fixed-point number n, the second section is a single little case letter 'e', and the last part is an integer which is the exponent of 10. Please complete the following tasks: 1. (5 points) Defining a regular grammar for the syntactic structure of real values. You may use [0-9] to denote a number character. 2. (5 points) Implementing a Scheme program which must have a function read-number which returns a list of the characters of the user input string which is a valid representation of a real value, or displays the information of the syntax error. Besides the Scheme source code, you are also required to submit a file showing the definition of the regular grammar based on which your program is built. Some Testing Examples: "123456" -> (#\1 #\2 #\3 #\4 #\5 #\6) "1.23" (#\1 #. #\2 #\3) "1.23000" > (#\1 #. #12 #\3 #\O #\O #\0) "-0.25e4" -> (#\- #\0 #\. #12 #\5 #\e #14) Syntax Errore "0..24" Syntax Error - Implementation Task:- e We are going to implement a tokenizer recognizing strings which are well-defined representations for real values using the functional programming language Scheme in the DrRacket IDE. We consider the following three formats to define a real value: A. Integer numbers. A valid string should only contain digits except the signs "+" and "-", such that "+" is neglectable if the number is nonnegative. It is allowed to have zeros at the beginning of the string. B. Fixed-point numbers. A valid string should have the integer part and the fractional part. The sign "+" is optional if the number is nonnegative. C. Scientific notations. For example, the number 4321.768 can be represented by the scientific notation 4.321768e3, or 4.321768e+3. The number 0.000012 can be represented by le-5. Therefore a scientific notation has 3 sections, the first section is a fixed-point number n, the second section is a single little case letter 'e', and the last part is an integer which is the exponent of 10. Please complete the following tasks: 1. (5 points) Defining a regular grammar for the syntactic structure of real values. You may use [0-9] to denote a number character. 2. (5 points) Implementing a Scheme program which must have a function read-number which returns a list of the characters of the user input string which is a valid representation of a real value, or displays the information of the syntax error. Besides the Scheme source code, you are also required to submit a file showing the definition of the regular grammar based on which your program is built. Some Testing Examples: "123456" -> (#\1 #\2 #\3 #\4 #\5 #\6) "1.23" (#\1 #. #\2 #\3) "1.23000" > (#\1 #. #12 #\3 #\O #\O #\0) "-0.25e4" -> (#\- #\0 #\. #12 #\5 #\e #14) Syntax Errore "0..24" Syntax Error

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

Consider this article:...

Answered: 1 week ago