← RGPV CS-501 Theory of Computation November 2023 Solved Paper
Question
Construct a context-free grammar that generates integers.
Asked in: CS-501 | November 2023 | 4(ii)
Answer
Assume decimal integers with optional sign and no leading zeros except zero. Use S→N|+N|-N; N→0|DT; D→1|2|3|4|5|6|7|8|9; T→ET|ε; E→0|D. This generates signed and unsigned decimal integers. If leading zeros are allowed, replace N with ET. The convention about signs and leading zeros is not specified in the question.
← RGPV CS-501 Theory of Computation November 2023 Solved Paper
Discussion
Ask a question, share your thoughts or report an error.
Sign in to participate in the discussion.
Join the discussion