Question: Consider the following CFG for floating-point constants, without exponential notation. (Note that this exercise is somewhat artificial: the language in question is regular, and would
Consider the following CFG for floating-point constants, without exponential notation. (Note that this exercise is somewhat artificial: the language in question is regular, and would be handled by the scanner of a typical compiler.)
C → digits . digits
digits → digit more digits
more digits → digits | ∈
digit → 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Augment this grammar with attribute rules that will accumulate the value of the constant into a val attribute of the root of the parse tree. Your answer should be S-attributed.
Step by Step Solution
3.56 Rating (163 Votes )
There are 3 Steps involved in it
C digits digits2 Cval digitsval digits2val x10 digit moredigits digits more digits digitsval di... View full answer
Get step-by-step solutions from verified subject matter experts
