- #1
blob84
- 25
- 0
Homework Statement
Write a grammar that recognize a C variable declaration made up only of legal combinations of the following keywords: int char float double signed unsigned long short volatile const
and a variable name.
The grammar should be able to accepts all such legal declarations for example:
volatile unsigned int a; ...
but :
volatile signed unsigned int a;
should not be accepted.
Homework Equations
declaration ::= variable
The Attempt at a Solution
1. declarations ::= variable ; declaration
2. variable ::= keyword name
3. keyword ::= type
4. type ::= type-int | type-char | float | double
5. type-int ::= int type-l type-sign
6. type-char ::= char type-sign
7. type-sign ::= signed | unsigned | empty
8. type-l ::= long | short | empty
I think that my solution is not correct.