Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Build a parser generator that implements LL(1) PREDICT, FIRST and FOLLOW sets co

ID: 3602349 • Letter: B

Question

Build a parser generator that implements LL(1) PREDICT, FIRST and FOLLOW sets construction in a purely functional subset of Scheme.

The key function you are to implement is the following:

(define parse-table

(lambda (grammar)

;;; your code here;

))

The input grammar must consist of a list of lists, one per non-terminal in the grammar. The first element of each sublist should be the non-terminal; the remaining elements should be the right-hand sides of the productions for which that non-terminal is the left-hand side. The sublist for the start symbol must come first. Every grammar symbol must be represented as a quoted string. As an example, here is our familiar LL(1) calculator grammar in the required format:

(define calc-gram

‘(("P" ("SL" "$$"))

("SL" ("S" "SL") ())

("S" ("id" ":=" "E") ("read" "id") ("write" "E"))

("E" ("T" "TT"))

("T" ("F" "FT"))

("TT" ("ao" "T" "TT") ())

("FT" ("mo" "F" "FT") ())

("ao" ("+") ("-"))

("mo" ("*") ("/"))

("F" ("id") ("num") ("(" "E" ")"))

))

Explanation / Answer

a parser generator that implements LL(1) PREDICT, FIRST and FOLLOW sets construction in a purely functional subset of Scheme.

The key function you are to implement is the following:

Build a parser generator that implements LL(1) PREDICT, FIRST and FOLLOW sets construction in a purely functional subset of Scheme.

The key function you are to implement is the following:

The input grammar must consist of a list of lists, one per non-terminal in the grammar. The first element of each sublist should be the non-terminal; the remaining elements should be the right-hand sides of the productions for which that non-terminal is the left-hand side. The sublist for the start symbol must come first. Every grammar symbol must be represented as a quoted string. As an example, here is our familiar LL(1) calculator grammar in the required format:

Build a parser generator that implements LL(1) PREDICT, FIRST and FOLLOW sets construction in a purely functional subset of Scheme.

The key function you are to implement is the following:

  (define parse-table      (lambda (grammar)      ;;; your code here;   ))  

The input grammar must consist of a list of lists, one per non-terminal in the grammar. The first element of each sublist should be the non-terminal; the remaining elements should be the right-hand sides of the productions for which that non-terminal is the left-hand side. The sublist for the start symbol must come first. Every grammar symbol must be represented as a quoted string. As an example, here is our familiar LL(1) calculator grammar in the required format:

  (define calc-gram      '(("P" ("SL" "$$"))        ("SL" ("S" "SL") ())        ("S" ("id" ":=" "E") ("read" "id") ("write" "E"))        ("E" ("T" "TT"))        ("T" ("F" "FT"))        ("TT" ("ao" "T" "TT") ())        ("FT" ("mo" "F" "FT") ())        ("ao" ("+") ("-"))        ("mo" ("*") ("/"))        ("F" ("id") ("num") ("(" "E" ")"))))  
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote