Answered step by step
Verified Expert Solution
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
- 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started