Suppose that in a programming language decimal, binary and hexadecimal literals can be assigned to an unsigned integer variable. Decimal literals consist of one or more digits, and do not begin with zero (0). To specify a binary literal, the prefix 0b or 0B is added to the binary number. To specify a hexadecimal literal, the prefix 0x or 0X is added to the hexadecimal number. Any length constraint specifying the number of digits in literals should not be taken into consideration in your solution. The following are examples: 20, 105, 68930, …. are decimal literals. 0b101, 0b0101, 0B101, …. are binary literals. 0x9A4, 0xE3F, 0X87C, …. are hexadecimal literals. a) Define the syntax for those literals using BNF (Backus-Naur Form) notation. b) Build a deterministic finite state machine that will recognize those literals.
Suppose that in a programming language decimal, binary and hexadecimal literals can be assigned to an unsigned integer variable. Decimal literals consist of one or more digits, and do not begin with zero (0). To specify a binary literal, the prefix 0b or 0B is added to the binary number. To specify a hexadecimal literal, the prefix 0x or 0X is added to the hexadecimal number. Any length constraint specifying the number of digits in literals should not be taken into consideration in your solution. The following are examples:
20, 105, 68930, …. are decimal literals.
0b101, 0b0101, 0B101, …. are binary literals.
0x9A4, 0xE3F, 0X87C, …. are hexadecimal literals.
a) Define the syntax for those literals using BNF (Backus-Naur Form) notation.
b) Build a deterministic finite state machine that will recognize those literals.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images