Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1 Show the decorated finite state automaton for recognizing integer constant (INTCONST) tokens, and computing the numerical value of the corresponding lexeme, when the
Problem 1 Show the decorated finite state automaton for recognizing integer constant (INTCONST) tokens, and computing the numerical value of the corresponding lexeme, when the constant can be specified as either a decimal (base-10) constant or a hexadecimal (base-16) constant. Thus, an integer constant token is given by either of the following patterns: 1. a nonempty sequence of decimal digits (0, 1, .., 9); the value of the constant is computed in base 10; or 2. a sequence beginning with the characters 0x followed by a nonempty sequence of digits 0...9 and letters a.f; the value of the constant is computed in base 16. You can make the following assumptions: the current input character is available in a variable ch; the value computed by your FSA can be assigned to a variable lval when the FSA returns a token. If you want, you can define a helper function to compute the numerical value of an input character -- but if you do this, make sure you show the code for the helper function. Example If the input character sequence is 10o the lexeme matched by your FSA should be 100 and the value computed should be one hundred. If the input character sequence is ox100 the lexeme matched by your FSA should be 0x100 and the value computed should be two hundred and fifty six. Problem 1 Show the decorated finite state automaton for recognizing integer constant (INTCONST) tokens, and computing the numerical value of the corresponding lexeme, when the constant can be specified as either a decimal (base-10) constant or a hexadecimal (base-16) constant. Thus, an integer constant token is given by either of the following patterns: 1. a nonempty sequence of decimal digits (0, 1, .., 9); the value of the constant is computed in base 10; or 2. a sequence beginning with the characters 0x followed by a nonempty sequence of digits 0...9 and letters a.f; the value of the constant is computed in base 16. You can make the following assumptions: the current input character is available in a variable ch; the value computed by your FSA can be assigned to a variable lval when the FSA returns a token. If you want, you can define a helper function to compute the numerical value of an input character -- but if you do this, make sure you show the code for the helper function. Example If the input character sequence is 10o the lexeme matched by your FSA should be 100 and the value computed should be one hundred. If the input character sequence is ox100 the lexeme matched by your FSA should be 0x100 and the value computed should be two hundred and fifty six
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