2. Below is the LL(1) parse table for a simple grammar for shell commands, con- sisting of a command name followed by (p

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: 899604
Joined: Mon Aug 02, 2021 8:13 am

2. Below is the LL(1) parse table for a simple grammar for shell commands, con- sisting of a command name followed by (p

Post by answerhappygod »

2 Below Is The Ll 1 Parse Table For A Simple Grammar For Shell Commands Con Sisting Of A Command Name Followed By P 1
2 Below Is The Ll 1 Parse Table For A Simple Grammar For Shell Commands Con Sisting Of A Command Name Followed By P 1 (58.77 KiB) Viewed 81 times
2. Below is the LL(1) parse table for a simple grammar for shell commands, con- sisting of a command name followed by (perhaps) some options and then some filenames. The start symbol is Shell. The terminals are com, opt, file. opt file $ com Shell com Args Args Opts Files Opts Files Opts Files Opts Files opt Opts file Files E € [10 marks] (a) Show how the LL(1) parsing algorithm executes on the input string com opt showing at each stage the operation performed, remaining input and stack state. Use the table format adopted in Lecture 23. (b) Explain what happens if we try to run the algorithm on the input com com How exactly does the algorithm detect the error? (c) One reason that LL(1) parsing may sometimes fail is that a predicted ter- minal does not match the symbol appearing next in the input. Could this ever happen for the grammar considered above? Justify your answer. (d) Consider now the following grammar (with start symbol S) for even-length palindromic strings over {a,b}: SelaSa bSb [5 marks] [4 marks Is this grammar ambiguous? Is it LL(1)? Briefly justify your answers. [6 marks]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply