Given the following production rules for hexadecimal integer
Given the following production rules for hexadecimal integers:
What are the terminal symbols?
What are the non-terminal symbols?
Use the production rules to show that “0xff” (without the quotes) is a hexidecimal integer.
| HexInteger -> HexPrefix HexValue HexPrefix -> 0x HexValue -> HixValue HexDigit | HexDigit HexDigit -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f |
What is the starting symbol? |
Solution
Starting symbol----->HexInteger
Terminal symbols---->0x, 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f
Non-terminal symbols------>HexPrefix, HexValue, HexDigit
The production rules to show that “0xff” (without the quotes) is a hexidecimal integer------>
(0x)(f)(f) ----> (HexPrefix) (HexDigit) (HexDigit) -----> (HexPrefix) (HexValue HexDigit) ------> (HexPrefix HexValue)---->HexInteger
