Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!