static int add_command_token(lua_State * L) { int nargs = lua_gettop(L); if (nargs == 2) return push_token_table(L, add_command_token(to_token_table(L, 1), lua_tostring(L, 2))); else return push_token_table(L, add_command_token(to_token_table(L, 1), lua_tostring(L, 2), lua_tostring(L, 3))); }
void init_token_table(token_table & t) { pair<char const *, unsigned> builtin[] = {{"fun", 0}, {"Pi", 0}, {"let", 0}, {"in", 0}, {"at", 0}, {"have", 0}, {"assert", 0}, {"suppose", 0}, {"show", 0}, {"suffices", 0}, {"obtain", 0}, {"if", 0}, {"then", 0}, {"else", 0}, {"by", 0}, {"by+", 0}, {"hiding", 0}, {"replacing", 0}, {"renaming", 0}, {"from", 0}, {"(", g_max_prec}, {")", 0}, {"{", g_max_prec}, {"}", 0}, {"_", g_max_prec}, {"[", g_max_prec}, {"]", 0}, {"⦃", g_max_prec}, {"⦄", 0}, {".{", 0}, {"Type", g_max_prec}, {"{|", g_max_prec}, {"|}", 0}, {"⊢", 0}, {"⟨", g_max_prec}, {"⟩", 0}, {"^", 0}, {"↑", 0}, {"▸", 0}, {"using", 0}, {"|", 0}, {"!", g_max_prec}, {"?", 0}, {"with", 0}, {"...", 0}, {",", 0}, {".", 0}, {":", 0}, {"::", 0}, {"calc", 0}, {"rewrite", 0}, {"xrewrite", 0}, {"krewrite", 0}, {"esimp", 0}, {"fold", 0}, {"unfold", 0}, {"with_options", 0}, {"simp", 0}, {"generalize", 0}, {"as", 0}, {":=", 0}, {"--", 0}, {"#", 0}, {"(*", 0}, {"/-", 0}, {"begin", g_max_prec}, {"begin+", g_max_prec}, {"abstract", g_max_prec}, {"proof", g_max_prec}, {"qed", 0}, {"@", g_max_prec}, {"sorry", g_max_prec}, {"+", g_plus_prec}, {g_cup, g_cup_prec}, {"->", g_arrow_prec}, {"?(", g_max_prec}, {"⌞", g_max_prec}, {"⌟", 0}, {"match", 0}, {"<d", g_decreasing_prec}, {"renaming", 0}, {"extends", 0}, {nullptr, 0}}; char const * commands[] = {"theorem", "axiom", "axioms", "variable", "protected", "private", "reveal", "definition", "example", "coercion", "abbreviation", "noncomputable", "variables", "parameter", "parameters", "constant", "constants", "[persistent]", "[visible]", "[instance]", "[trans-instance]", "[none]", "[class]", "[coercion]", "[reducible]", "[irreducible]", "[semireducible]", "[quasireducible]", "[simp]", "[congr]", "[parsing-only]", "[multiple-instances]", "[symm]", "[trans]", "[refl]", "[subst]", "[recursor", "evaluate", "check", "eval", "[wf]", "[whnf]", "[priority", "[unfold-full]", "[unfold-hints]", "[constructor]", "[unfold", "print", "end", "namespace", "section", "prelude", "help", "import", "inductive", "record", "structure", "module", "universe", "universes", "local", "precedence", "reserve", "infixl", "infixr", "infix", "postfix", "prefix", "notation", "tactic_infixl", "tactic_infixr", "tactic_infix", "tactic_postfix", "tactic_prefix", "tactic_notation", "exit", "set_option", "open", "export", "override", "calc_subst", "calc_refl", "calc_trans", "calc_symm", "tactic_hint", "add_begin_end_tactic", "set_begin_end_tactic", "instance", "class", "multiple_instances", "find_decl", "attribute", "persistent", "include", "omit", "migrate", "init_quotient", "init_hits", "#erase_cache", "#projections", "#telescope_eq", "#compile", "#accessible", nullptr}; pair<char const *, char const *> aliases[] = {{g_lambda_unicode, "fun"}, {"forall", "Pi"}, {g_forall_unicode, "Pi"}, {g_pi_unicode, "Pi"}, {g_qed_unicode, "qed"}, {nullptr, nullptr}}; pair<char const *, char const *> cmd_aliases[] = {{"lemma", "theorem"}, {"proposition", "theorem"}, {"premise", "variable"}, {"premises", "variables"}, {"corollary", "theorem"}, {"hypothesis", "parameter"}, {"conjecture", "parameter"}, {"record", "structure"}, {nullptr, nullptr}}; auto it = builtin; while (it->first) { t = add_token(t, it->first, it->second); it++; } auto it2 = commands; while (*it2) { t = add_command_token(t, *it2); ++it2; } auto it3 = aliases; while (it3->first) { t = add_token(t, it3->first, it3->second, 0); it3++; } t = add_token(t, g_arrow_unicode, "->", get_arrow_prec()); t = add_token(t, g_decreasing_unicode, "<d", get_decreasing_prec()); auto it4 = cmd_aliases; while (it4->first) { t = add_command_token(t, it4->first, it4->second); ++it4; } }
void init_token_table(token_table & t) { pair<char const *, unsigned> builtin[] = {{"fun", 0}, {"Pi", 0}, {"let", 0}, {"in", 0}, {"at", 0}, {"have", 0}, {"assume", 0}, {"show", 0}, {"suffices", 0}, {"do", 0}, {"if", 0}, {"then", 0}, {"else", 0}, {"by", 0}, {"hiding", 0}, {"replacing", 0}, {"renaming", 0}, {"from", 0}, {"(", g_max_prec}, {"`(", g_max_prec}, {"``(", g_max_prec}, {"```(", g_max_prec}, {"`[", g_max_prec}, {"`", g_max_prec}, {"%%", g_max_prec}, {"()", g_max_prec}, {"(::)", g_max_prec}, {")", 0}, {"'", 0}, {"{", g_max_prec}, {"}", 0}, {"_", g_max_prec}, {"[", g_max_prec}, {"#[", g_max_prec}, {"]", 0}, {"⦃", g_max_prec}, {"⦄", 0}, {".{", 0}, {"{!", g_max_prec}, {"!}", 0}, {"Type", g_max_prec}, {"Type*", g_max_prec}, {"Sort", g_max_prec}, {"Sort*", g_max_prec}, {"(:", g_max_prec}, {":)", 0}, {".(", g_max_prec}, {"._", g_max_prec}, {"⟨", g_max_prec}, {"⟩", 0}, {"^", 0}, {"//", 0}, {"|", 0}, {"with", 0}, {"without", 0}, {"..", 0}, {"...", 0}, {",", 0}, {".", 0}, {":", 0}, {"!", 0}, {"calc", 0}, {":=", 0}, {"--", 0}, {"#", g_max_prec}, {"/-", 0}, {"/--", 0}, {"/-!", 0}, {"begin", g_max_prec}, {"using", 0}, {"@@", g_max_prec}, {"@", g_max_prec}, {"sorry", g_max_prec}, {"+", g_plus_prec}, {"->", g_arrow_prec}, {"<-", 0}, {"match", 0}, {"^.", g_max_prec+1}, {"renaming", 0}, {"extends", 0}, {nullptr, 0}}; char const * commands[] = {"theorem", "axiom", "axioms", "variable", "protected", "private", "hide", "definition", "meta", "mutual", "example", "noncomputable", "abbreviation", "variables", "parameter", "parameters", "constant", "constants", "using_well_founded", "[whnf]", "end", "namespace", "section", "prelude", "import", "inductive", "coinductive", "structure", "class", "universe", "universes", "local", "precedence", "reserve", "infixl", "infixr", "infix", "postfix", "prefix", "notation", "set_option", "open", "export", "@[", "attribute", "instance", "include", "omit", "init_quotient", "declare_trace", "add_key_equivalence", "run_cmd", "#check", "#reduce", "#eval", "#print", "#help", "#exit", "#compile", "#unify", nullptr}; pair<char const *, char const *> aliases[] = {{"λ", "fun"}, {"forall", "Pi"}, {"∀", "Pi"}, {"Π", "Pi"}, {"(|", "⟨"}, {"|)", "⟩"}, {nullptr, nullptr}}; pair<char const *, char const *> cmd_aliases[] = {{"lemma", "theorem"}, {"def", "definition"}, {nullptr, nullptr}}; auto it = builtin; while (it->first) { t = add_token(t, it->first, it->second); it++; } auto it2 = commands; while (*it2) { t = add_command_token(t, *it2); ++it2; } auto it3 = aliases; while (it3->first) { t = add_token(t, it3->first, it3->second, 0); it3++; } t = add_token(t, "→", "->", get_arrow_prec()); t = add_token(t, "←", "<-", 0); auto it4 = cmd_aliases; while (it4->first) { t = add_command_token(t, it4->first, it4->second); ++it4; } }