Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CFGs and Parsing 6. (1 point) Consider the following CFG. SSaAaAaSbSTTcT Prove the CFG is ambiguous by showing two distinct leftmost derivations of aaaa. 7.

image text in transcribedimage text in transcribedimage text in transcribed CFGs and Parsing 6. (1 point) Consider the following CFG. SSaAaAaSbSTTcT Prove the CFG is ambiguous by showing two distinct leftmost derivations of "aaaa". 7. (1 point) List the first sets for the following grarnmar: SaBRwBdRnRc 8. (1 point) Consider the following CFG. Can it be parsed via rearsive descent parsing? If your answer is yes, you do not need to do anything for this part. If your answer is no, please fix the gramrnar so that it can be parsed by recursive descent parsing. SABSABABAaaBbb 9. (1 point) Define a CFG that describes the language. axbyczwherey=x+3z,x0andz0 10. (1 point) Consider the following parser. The list of valid tokens are: "let", "in", "=", "a", "b", "n". exception Parsetrror of string let lookahead (toks: string list) : string - match toks with [ []> h::zh let match_tok (toks: string list) (a : string) : string list match toks with h:t when a hs toks | _-> raise (ParseError bad match ") Iet rec parse_s toks - match toks with I "let' : toks -s let toks - parse_ toks in let toks - match_tok '-' toks in let toks - parse_E toks in let toks - match_tok 'in' toks in parse_s toks | _- - parse_E toks let rec parse_ toks - match toks with I' a ' : : toks > toks | b " : : toks -> toks | _ - raise (ParseError ) let rec parse_E toks - match toks with I ' n ' : : toks > toks | _ > parse_T toks Write the CFG that this parser is built for below

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions