/*
Copyright 2024 Ondrej Lhotak. All rights reserved.
Permission is granted for private study use by students registered in
CS 241E in the Fall 2024 term.
The contents of this file may not be published, in whole or in part,
in print or electronic form.
The contents of this file may be included in work submitted for CS
241E assignments in Fall 2024. The contents of this file may not be
submitted, in whole or in part, for credit in any other course.
*/
package cs241e.assignments
import cs241e.scanparse.DFAs.Token
import cs241e.scanparse.Grammars.*
object A8 {
/* Hint: If you find the implementations in this file tedious, consider writing yourself some helper methods. */
/** A sample grammar. */
val grammar = parseGrammar(
"""
S BOF A EOF
A x
A A x
""")
/** A parse tree of the string `BOF x EOF` generated by `grammar`. */
val oneX: Tree =
new Tree(Token("S"), Seq(
new Tree(Token("BOF")),
new Tree(Token("A"), Seq(
new Tree(Token("x"))
)),
new Tree(Token("EOF"))
))
/** A parse tree of the string `BOF x x EOF` generated by `grammar`. */
lazy val twoXes: Tree = ???
/** A parse tree of the string `BOF x x x EOF` generated by `grammar`. */
lazy val threeXes: Tree = ???
/** A sample ambiguous grammar. */
val ambiguousGrammar = parseGrammar(
"""
S BOF A EOF
A x
A A x A
""")
/** A parse tree of some string for which `ambiguousGrammar` is ambiguous. */
lazy val tree1: Tree = ???
/** A **different** parse tree of the **same** string as `tree1` according to `ambiguousGrammar`. */
lazy val tree2: Tree = ???
}