signature NUNCHAKU_MODEL = sig type ident = Nunchaku_Problem.ident type ty = Nunchaku_Problem.ty type tm = Nunchaku_Problem.tm type name_pool = Nunchaku_Problem.name_pool
type ty_entry = ty * tm list type tm_entry = tm * tm
val ugly_nun_model: name_pool -> nun_model -> nun_model
datatype token =
Ident of ident
| Symbol of ident
| Atom of ident * int
| End_of_Stream
val parse_tok: ''a -> ''a list -> ''a * ''a list val parse_ident: token list -> ident * token list val parse_id: ident -> token list -> token * token list val parse_sym: ident -> token list -> token * token list val parse_atom: token list -> (ident * int) * token list val nun_model_of_str: string -> nun_model end;
fun allocate_ugly pool (nice, ugly_sugg) =
allocate_nice (swap_name_pool pool) (nice, ugly_sugg) ||> swap_name_pool;
fun ugly_ident nice (pool as {ugly_of_nice, ...}) =
(case Symtab.lookup ugly_of_nice nice of
NONE => allocate_ugly pool (nice, nice)
| SOME ugly => (ugly, pool));
fun ugly_nun_model pool model =
fst (fold_map_nun_model_idents ugly_ident model pool);
datatype token =
Ident of ident
| Symbol of ident
| Atom of ident * int
| End_of_Stream;
val rev_str = String.implode o rev o String.explode;
fun atom_of_str s =
(case first_field "_" (rev_str s) of
SOME (rev_suf, rev_pre) => let val pre = rev_str rev_pre; val suf = rev_str rev_suf; in
(case Int.fromString suf of
SOME j => Atom (ident_of_str pre, j)
| NONE => raise Fail ("ill-formed atom: " ^ s)) end
| NONE => raise Fail ("ill-formed atom: " ^ s));
fun is_alnum_etc_char c = Char.isAlphaNum c orelse c = #"_" orelse c = #"/";
fun is_dollar_alnum_etc_char c = c = #"$" orelse is_alnum_etc_char c;
val multi_ids =
[nun_arrow, nun_assign, nun_conj, nun_disj, nun_implies, nun_unparsable, nun_irrelevant];
val nun_dollar_anon_fun_prefix_exploded = String.explode nun_dollar_anon_fun_prefix; val [nun_dollar_char] = String.explode nun_dollar;
fun next_token [] = (End_of_Stream, [])
| next_token (c :: cs) = if Char.isSpace c then
next_token cs elseif c = nun_dollar_char then letval n = find_index (not o is_dollar_alnum_etc_char) cs in
(if n = ~1 then (cs, []) else chop n cs)
|>> (String.implode
#> (if is_prefix (op =) nun_dollar_anon_fun_prefix_exploded cs then ident_of_str #> Ident else atom_of_str)) end elseif is_alnum_etc_char c then letval n = find_index (not o is_alnum_etc_char) cs in
(if n = ~1 then (cs, []) else chop n cs)
|>> (cons c #> String.implode #> ident_of_str #> Ident) end else let fun next_multi id = let val s = str_of_ident id; val n = String.size s - 1; in if c = String.sub (s, 0) andalso
is_prefix (op =) (String.explode (String.substring (s, 1, n))) cs then
SOME (Symbol id, drop n cs) else
NONE end; in
(case get_first next_multi multi_ids of
SOME res => res
| NONE => (Symbol (ident_of_str (String.str c)), cs)) end;
val tokenize = let fun toks cs =
(case next_token cs of
(End_of_Stream, []) => []
| (tok, cs') => tok :: toks cs'); in
toks o String.explode end;
val parse_ident = Scan.some (try (fn Ident id => id)); val parse_id = parse_tok o Ident; val parse_sym = parse_tok o Symbol; val parse_atom = Scan.some (try (fn Atom id_j => id_j));
val confusing_ids = [nun_else, nun_then, nun_with];
val parse_confusing_id = Scan.one (fn Ident id => member (op =) confusing_ids id | _ => false);
fun parse_ty toks =
(parse_ty_arg -- Scan.option (parse_sym nun_arrow -- parse_ty)
>> (fn (ty, NONE) => ty
| (lhs, SOME (Symbol id, rhs)) => NType (id, [lhs, rhs]))) toks and parse_ty_arg toks =
(parse_ident >> (rpair [] #> NType)
|| parse_sym nun_lparen |-- parse_ty --| parse_sym nun_rparen) toks;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.