Tag: CS-501

CFG generating integers

AnswerAssume 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…

Read more →

CFG for strings without bbb

AnswerG=({S,A,B},{a,b},P,S), where S→aS|bA|ε, A→aS|bB|ε, B→aS|ε. The variables represent zero, one or two trailing b symbols. No b production exists from B, so…

Read more →