[Solved]-Using C C Note Problem Designed Show Dfa Pda Used Compilers Dfa Used Finding Tokens Proble Q37206369
USING C++ or C , Note: This problem is designed to show you howDFA and PDA are used in Compilers. DFA is used for finding thetokens (Problem 1) and PDA for syntax (Problem 2
Part I – We have the following input file: (for foreign studentsthe name here are of well know comics)
larry = 27
curly = 19
moe = 8
groucho = 11
harpo = larry+curly
harpo = larry-curly
harpo = larry*curly
harpo = larry/curly
harpo = larry*curly+moe*groucho
We need to define a DFA which will give the output varioustokens. In this case, the identifiers will be larry, curly, moe ,groucho , and harpo. The operators will be /, +, -, *, +, = andintegers ( . They will come as an output file.
Here is A DFA for this purpose. (q0 is the starting state, q1,q2 and q3 are accepting states (if it is accepted in state q2, thetoken is an operator, if it is accepted in q1, the tokenis an identifier ( , any string that starts with aletter and then continues with any combination of letters andinteger digits. The maximum number of characters for any identifiershould be 10.)
and q3 if it is an integer (intLit) – youcan limit the number of digits to 10). One should writedown what strings are accepted (token) and list the names ofnew tokens .
State operator alpha intLit
q0 q2 q1 q3
q1 q1 q1
q2
q3 q4 q3
q4 q4 q4 q4
Expert Answer
Answer to USING C++ or C , Note: This problem is designed to show you how DFA and PDA are used in Compilers. DFA is used for findi… . . .
OR

