grammar = [("program", [[(True, "exp")],
                      [(True, "decs")],
                      [(False, "5")]]),
         ("exp", [[(False, "nil")],
                  [(False, "5")],
                  [(False, "\"totor\"")],
                  [(True, "type-id"), (False, " ["), (True, "exp"), (False, "] of "), (True, "exp")],
                  [(True, "type-id"), (False, " {} ")],
                  [(True, "type-id"), (False, " {"), (True, "id"), (False, " = "), (True, "exp"), (False, "} ")],
                  [(True, "type-id"), (False, " {"), (True, "id"), (False, " = "), (True, "exp"), (False, ", "),
                   (True, "id"), (False, " = "), (True, "exp"), (False, "} ")],
                  [(False, "new "), (True, "type-id")],
                  [(True, "lvalue")],
                  [(True, "id"), (False, "()")],
                  [(True, "id"), (False, "("), (True, "exp"), (False, ", "), (True, "exp"), (False, ")")],
                  [(True, "lvalue"), (False, "."), (True, "id"), (False, "()")],
                  [(True, "lvalue"), (False, "."), (True, "id"), (False, "("), (True, "exp"), (False, ", "),
                   (True, "exp"), (False, ")")],
                  [(False, "-"), (True, "exp")],
                  [(True, "exp"), (True, "op"), (True, "exp")],
                  [(False, "("), (True, "exps"), (False, ")")],
                  [(False, "()")],
                  [(True, "lvalue"), (False, " := "), (True, "exp")],
                  [(False, "if "), (True, "exp"), (False, " then "), (True, "exp")],
                  [(False, "if "), (True, "exp"), (False, " then "), (True, "exp"), (False, " else "), (True, "exp")],
                  [(False, "while "), (True, "exp"), (False, " do "), (True, "exp")],
                  [(False, "for "), (True, "id"), (False, " := "), (True, "exp"), (False, " to "), (True, "exp"),
                   (False, " do "), (True, "exp")],
                  [(False, "break")],
                  [(False, "let "), (True, "decs"), (False, " in "), (True, "exps"), (False, " end")],
                  [(False, "let "), (True, "decs"), (False, " in end")]]),
         ("lvalue", [[(False, "x")],
                     [(True, "lvalue"), (False, "."), (True, "id")],
                     [(True, "lvalue"), (False, "["), (True, "exp"), (False, "]")]]),
         ("exps", [[(True, "exp")],
                   [(False, "5")],
                   [(True, "exp"), (False, " ; "), (True, "exps")]]),
         ("decs", [[(False, "")],
                   [(True, "decs2")]]),
         ("decs2", [[(True, "dec")],
                    [(False, "var x := 5")],
                    [(True, "dec"), (False, " "), (True, "decs2")]]),
         ("dec", [[(False, "type "), (True, "id"), (False, " = "), (True, "ty")],
                  [(False, "class "), (True, "id"), (False, " extends "), (True, "type-id"), (False, " {"),
                   (True, "classfields"), (False, "} ")],
                  [(False, "class "), (True, "id"), (False, " {"), (True, "classfields"), (False, "} ")],
                  [(True, "vardec")],
                  [(False, "var x := 5")],
                  [(False, "function "), (True, "id"), (False, "("), (True, "tyfields"), (False, ") : "),
                   (True, "type-id"), (False, " = "), (True, "exp")],
                  [(False, "function "), (True, "id"), (False, "("), (True, "tyfields"), (False, ") = "),
                   (True, "exp")],
                  [(False, "import \"empty.tih\"")]]),
         ("vardec", [[(False, "var "), (True, "id"), (False, " := "), (True, "exp")],
                     [(False, "var x := 5")],
                     [(False, "var "), (True, "id"), (False, " : "), (True, "type-id"), (False, " := "),
                      (True, "exp")]]),
         ("classfields", [[(False, "")],
                          [(True, "classfields2")]]),
         ("classfields2", [[(True, "classfield")],
                           [(False, "var x := 5")],
                           [(True, "classfield"), (False, " "), (True, "classfields2")]]),
         ("classfield", [[(True, "vardec")],
                         [(False, "var x := 5")],
                         [(False, "method "), (True, "id"), (False, "("), (True, "tyfields"), (False, ") : "),
                          (True, "type-id"), (False, " = "), (True, "exp")],
                         [(False, "method "), (True, "id"), (False, "("), (True, "tyfields"), (False, ") = "),
                          (True, "exp")]]),
         ("ty", [[(False, "int")],
                 [(True, "type-id")],
                 [(False, "{"), (True, "tyfields"), (False, "}")],
                 [(False, "array of "), (True, "type-id")],
                 [(False, "class extends "), (True, "type-id"), (False, "{"), (True, "classfields"), (False, "}")],
                 [(False, "class {"), (True, "classfields"), (False, "}")]]),
         ("tyfields", [[(False, "")],
                       [(True, "tyfields2")]]),
         ("tyfields2", [[(True, "id"), (False, " : "), (True, "type-id")],
                        [(False, "x : int")],
                        [(True, "id"), (False, " : "), (True, "type-id"), (False, ", "), (True, "tyfields2")]]),
         ("type-id", [[(False, "int")]]),
         ("id", [[(False, "x")]]),
         ("op", [[(False, "+")],
                 [(False, "-")],
                 [(False, "*")],
                 [(False, "/")],
                 [(False, "&")],
                 [(False, "|")]])]