Problem Consider the following partial grammar: We have a datatype s to represent this: data S = S1 Char S Char S2 Char

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Problem Consider the following partial grammar: We have a datatype s to represent this: data S = S1 Char S Char S2 Char

Post by answerhappygod »

Problem Consider The Following Partial Grammar We Have A Datatype S To Represent This Data S S1 Char S Char S2 Char 1
Problem Consider The Following Partial Grammar We Have A Datatype S To Represent This Data S S1 Char S Char S2 Char 1 (68.93 KiB) Viewed 28 times
Problem Consider the following partial grammar: We have a datatype s to represent this: data S = S1 Char S Char S2 Char E deriving (Show, Eq) This grammar is LL. Write the corresponsing parsing function parses: [Char] -> (S, [Char]) that takes a list of characters and returns the corresponding s tree and remaining input. You can assume the existence of a properly written parsee that you may call, and that the E portion of the grammar (not shown here) introduces no ambiguities. If you need to test locally, you can pretend that E accepts any character given to it, and use this function: data E = E [Char] deriving (Show, Eq) S→ x Sy | ZE parseE parseE (x:xs) = (E [x], xs) Please don't submit that with your code or you will break the autograder and not get credit. Example [Char] -> (E, [Char]) Lib.hs Prelude> parses "xxxzayyy" (S1 'x' (S1 'x' (51 'x' (52 'z' (E "a")) 'y') 'y') 'y', []) Your Solution Starter Code 1 parses: [Char] > (S,[Char]) 2 parses = undefined
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply