Parse.parse_from_grammars : (parse_type.grammar * term_grammar.grammar) -> ((hol_type frag list -> hol_type) * (term frag list -> term))
- load "arithmeticTheory"; > val it = () : unit - val t = Term`2 + 3`; > val t = `2 + 3` : termThen the parse_from_grammars function is used to make the values Type and Term use the grammar present in the simpler theory of booleans. Using this function fails to parse numerals or even the + infix:
- val (Type,Term) = parse_from_grammars boolTheory.bool_grammars; > val Type = fn : hol_type frag list -> hol_type val Term = fn : term frag list -> term - Term`2 + 3`; <<HOL message: No numerals currently allowed.>> ! Uncaught exception: ! HOL_ERR <poly> - Term`x + y`; <<HOL message: inventing new type variable names: 'a, 'b.>> > val it = `x $+ y` : termBut, as the last example above also demonstrates, the pretty-printer is still dependent on the global grammar, and the global value of Term can still be accessed through the Parse structure:
- t; > val it = `2 + 3` : term - Parse.Term`2 + 3`; > val it = `2 + 3` : term