6.9.6. Bootstrapping

6.9.6. Bootstrapping

The function below is used to bootstrap the parser. We use the standard Python tokeniser, and contruct a grammar by hand to recognize grammars. The reduction functor is used to build a list of productions, the functions named in the grammar are attached to these productions. The grammar we will use is:
  G -> Plist
  Plist -> Plist newline P
  Plist -> P
  P -> LHS = RHS { func }
  RHS -> RHS sym
  RHS -> sym
We will immediately test the generated parser to parse a string representing a grammar, namely, the same grammar, which should generate an equivalent parser.
  G = Plist { build_grammar }
  Plist = Plist newline P { add_production_to_list }
  Plist = P { new_production_list }
  P = LHS = RHS "{" func "}" { build_production }
  RHS = RHS sym { add_sym_to_list }
  RHS = sym { new_RHS_list}


6.9.6.1. Test Tokeniser
6.9.6.2. Bootstrapping test