In old versions of Fortran that did not have the character data type, character strings were expressed in the following format: ::= H where the is a base-ten integer (≥ 1), H is a keyword (named after Herman Hollerith), and is a sequence of characters. The semantics of this string literal is correct if the base-ten numeral's numeric value matches the string's length. Write an attribute grammar using only synthesized attributes for the nonterminals in the definition. Below is an example of an attribute grammar that defines the meaning of binary numerals consisting only of Synthesized Attributes. Base your answer on the example below. Val - stands for the attribute Value. Len - stands for the attribute Length. Nonterminals Synthesized Attributes Inherited Attributes Val Val, Len Val :: , 2 Val ()<- Val ()+ Val ()/2lm (chinary digits binary digits> ::- Val ()2 Val (>2) + Val () Len () + Len ()+1 | Val () Val () Len ( ::= 0 Val ()0 | 1 Val ()1

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
In old versions of Fortran that did not have the character data type, character strings were
expressed in the following format:
<string literal> ::= <numeral> H <string>
where the <numeral> is a base-ten integer (≥ 1), H is a keyword (named after Herman
Hollerith), and <string> is a sequence of characters.
The semantics of this string literal is correct if the base-ten numeral's numeric value matches
the string's length.
Write an attribute grammar using only synthesized attributes for the nonterminals in the <string
literal> definition.
Below is an example of an attribute grammar that defines the meaning of binary numerals
consisting only of Synthesized Attributes.
Base your answer on the example below.
Val - stands for the attribute Value.
Len - stands for the attribute Length.
Nonterminals
<binary numeral>
<binary digits>
<bit>
Synthesized
Attributes
Inherited
Attributes
Val
Val, Len
Val
<binary numeral> :: <binary digits>, <binary digits>2
Val (<binary numeral>)<- Val (<binary digits>)+
Val (<binary digits>)/2lm (chinary digits
binary digits> ::-
<binary digits> <bit>
Val (<binary digits>)2 Val (<binary digits>>2) + Val (<bit>)
Len (<binary digits>) + Len (<binary digits>)+1
| <bit>
Val (<binary digits>) Val (<bit>)
Len (<binary digits) 1
<bit> ::=
0
Val (<bit>)0
| 1
Val (<bit>)1
Transcribed Image Text:In old versions of Fortran that did not have the character data type, character strings were expressed in the following format: <string literal> ::= <numeral> H <string> where the <numeral> is a base-ten integer (≥ 1), H is a keyword (named after Herman Hollerith), and <string> is a sequence of characters. The semantics of this string literal is correct if the base-ten numeral's numeric value matches the string's length. Write an attribute grammar using only synthesized attributes for the nonterminals in the <string literal> definition. Below is an example of an attribute grammar that defines the meaning of binary numerals consisting only of Synthesized Attributes. Base your answer on the example below. Val - stands for the attribute Value. Len - stands for the attribute Length. Nonterminals <binary numeral> <binary digits> <bit> Synthesized Attributes Inherited Attributes Val Val, Len Val <binary numeral> :: <binary digits>, <binary digits>2 Val (<binary numeral>)<- Val (<binary digits>)+ Val (<binary digits>)/2lm (chinary digits binary digits> ::- <binary digits> <bit> Val (<binary digits>)2 Val (<binary digits>>2) + Val (<bit>) Len (<binary digits>) + Len (<binary digits>)+1 | <bit> Val (<binary digits>) Val (<bit>) Len (<binary digits) 1 <bit> ::= 0 Val (<bit>)0 | 1 Val (<bit>)1
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT