| author | wenzelm | 
| Thu, 30 Jun 2011 14:51:32 +0200 | |
| changeset 43605 | 4f119a9ed37c | 
| parent 40627 | becf5d5187cc | 
| child 43947 | 9b00f09f7721 | 
| permissions | -rw-r--r-- | 
| 11523 | 1 | (* Title: Pure/General/scan.ML | 
| 2 | Author: Markus Wenzel and Tobias Nipkow, TU Muenchen | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 3 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 4 | Generic scanners (for potentially infinite input). | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 5 | *) | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 6 | |
| 24025 | 7 | infix 5 -- :-- :|-- |-- --| ^^; | 
| 25999 | 8 | infixr 5 ::: @@@; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 9 | infix 3 >>; | 
| 23699 | 10 | infixr 0 ||; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 11 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 12 | signature BASIC_SCAN = | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 13 | sig | 
| 14677 | 14 | (*error msg handler*) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 15 |   val !! : ('a * string option -> string) -> ('a -> 'b) -> 'a -> 'b
 | 
| 14677 | 16 | (*apply function*) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 17 |   val >> : ('a -> 'b * 'c) * ('b -> 'd) -> 'a -> 'd * 'c
 | 
| 14677 | 18 | (*alternative*) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 19 |   val || : ('a -> 'b) * ('a -> 'b) -> 'a -> 'b
 | 
| 14677 | 20 | (*sequential pairing*) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 21 |   val -- : ('a -> 'b * 'c) * ('c -> 'd * 'e) -> 'a -> ('b * 'd) * 'e
 | 
| 14677 | 22 | (*dependent pairing*) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 23 |   val :-- : ('a -> 'b * 'c) * ('b -> 'c -> 'd * 'e) -> 'a -> ('b * 'd) * 'e
 | 
| 24025 | 24 | (*projections*) | 
| 25 |   val :|-- : ('a -> 'b * 'c) * ('b -> 'c -> 'd * 'e) -> 'a -> 'd * 'e
 | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 26 |   val |-- : ('a -> 'b * 'c) * ('c -> 'd * 'e) -> 'a -> 'd * 'e
 | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 27 |   val --| : ('a -> 'b * 'c) * ('c -> 'd * 'e) -> 'a -> 'b * 'e
 | 
| 14677 | 28 | (*concatenation*) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 29 |   val ^^ : ('a -> string * 'b) * ('b -> string * 'c) -> 'a -> string * 'c
 | 
| 25999 | 30 |   val ::: : ('a -> 'b * 'c) * ('c -> 'b list * 'd) -> 'a -> 'b list * 'd
 | 
| 31 |   val @@@ : ('a -> 'b list * 'c) * ('c -> 'b list * 'd) -> 'a -> 'b list * 'd
 | |
| 14677 | 32 | (*one element literal*) | 
| 19291 | 33 | val $$ : string -> string list -> string * string list | 
| 19306 | 34 | val ~$$ : string -> string list -> string * string list | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 35 | end; | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 36 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 37 | signature SCAN = | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 38 | sig | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 39 | include BASIC_SCAN | 
| 23699 | 40 |   val prompt: string -> ('a -> 'b) -> 'a -> 'b
 | 
| 41 |   val error: ('a -> 'b) -> 'a -> 'b
 | |
| 42 |   val catch: ('a -> 'b) -> 'a -> 'b    (*exception Fail*)
 | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 43 | val fail: 'a -> 'b | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 44 |   val fail_with: ('a -> string) -> 'a -> 'b
 | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 45 | val succeed: 'a -> 'b -> 'a * 'b | 
| 15664 | 46 |   val some: ('a -> 'b option) -> 'a list -> 'b * 'a list
 | 
| 47 |   val one: ('a -> bool) -> 'a list -> 'a * 'a list
 | |
| 19291 | 48 | val this: string list -> string list -> string list * string list | 
| 14927 | 49 | val this_string: string -> string list -> string * string list | 
| 21858 
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
 wenzelm parents: 
19473diff
changeset | 50 |   val many: ('a -> bool) -> 'a list -> 'a list * 'a list
 | 
| 
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
 wenzelm parents: 
19473diff
changeset | 51 |   val many1: ('a -> bool) -> 'a list -> 'a list * 'a list
 | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 52 |   val optional: ('a -> 'b * 'a) -> 'b -> 'a -> 'b * 'a
 | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 53 |   val option: ('a -> 'b * 'a) -> 'a -> 'b option * 'a
 | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 54 |   val repeat: ('a -> 'b * 'a) -> 'a -> 'b list * 'a
 | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 55 |   val repeat1: ('a -> 'b * 'a) -> 'a -> 'b list * 'a
 | 
| 23699 | 56 |   val single: ('a -> 'b * 'a) -> 'a -> 'b list * 'a
 | 
| 57 |   val bulk: ('a -> 'b * 'a) -> 'a -> 'b list * 'a
 | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 58 |   val max: ('a * 'a -> bool) -> ('b -> 'a * 'b) -> ('b -> 'a * 'b) -> 'b -> 'a * 'b
 | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 59 |   val ahead: ('a -> 'b * 'c) -> 'a -> 'b * 'a
 | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 60 |   val unless: ('a -> 'b * 'a) -> ('a -> 'c * 'd) -> 'a -> 'c * 'd
 | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 61 |   val first: ('a -> 'b) list -> 'a -> 'b
 | 
| 14677 | 62 |   val state: 'a * 'b -> 'a * ('a * 'b)
 | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 63 |   val depend: ('a -> 'b -> ('c * 'd) * 'e) -> 'a * 'b -> 'd * ('c * 'e)
 | 
| 15664 | 64 |   val peek: ('a -> 'b -> 'c * 'd) -> 'a * 'b -> 'c * ('a * 'd)
 | 
| 65 |   val pass: 'a -> ('a * 'b -> 'c * ('d * 'e)) -> 'b -> 'c * 'e
 | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 66 |   val lift: ('a -> 'b * 'c) -> 'd * 'a -> 'b * ('d * 'c)
 | 
| 23699 | 67 |   val unlift: (unit * 'a -> 'b * ('c * 'd)) -> 'a -> 'b * 'd
 | 
| 15664 | 68 |   val trace: ('a list -> 'b * 'c list) -> 'a list -> ('b * 'a list) * 'c list
 | 
| 27731 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 69 | type 'a stopper | 
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 70 |   val stopper: ('a list -> 'a) -> ('a -> bool) -> 'a stopper
 | 
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 71 | val is_stopper: 'a stopper -> 'a -> bool | 
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 72 |   val finite': 'a stopper -> ('b * 'a list -> 'c * ('d * 'a list))
 | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 73 |     -> 'b * 'a list -> 'c * ('d * 'a list)
 | 
| 27731 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 74 |   val finite: 'a stopper -> ('a list -> 'b * 'a list) -> 'a list -> 'b * 'a list
 | 
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 75 |   val read: 'a stopper -> ('a list -> 'b * 'a list) -> 'a list -> 'b option
 | 
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 76 | val drain: string -> (string -> 'a -> 'b list * 'a) -> 'b stopper -> | 
| 23699 | 77 |     ('c * 'b list -> 'd * ('e * 'b list)) -> ('c * 'b list) * 'a -> ('d * ('e * 'b list)) * 'a
 | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 78 | type lexicon | 
| 27765 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 79 | val is_literal: lexicon -> string list -> bool | 
| 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 80 | val literal: lexicon -> (string * 'a) list -> (string * 'a) list * (string * 'a) list | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 81 | val empty_lexicon: lexicon | 
| 27765 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 82 | val extend_lexicon: string list -> lexicon -> lexicon | 
| 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 83 | val make_lexicon: string list list -> lexicon | 
| 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 84 | val dest_lexicon: lexicon -> string list | 
| 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 85 | val merge_lexicons: lexicon * lexicon -> lexicon | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 86 | end; | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 87 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 88 | structure Scan: SCAN = | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 89 | struct | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 90 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 91 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 92 | (** scanners **) | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 93 | |
| 23699 | 94 | (* exceptions *) | 
| 95 | ||
| 11523 | 96 | exception MORE of string option; (*need more input (prompt)*) | 
| 97 | exception FAIL of string option; (*try alternatives (reason of failure)*) | |
| 98 | exception ABORT of string; (*dead end*) | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 99 | |
| 23699 | 100 | fun !! err scan xs = scan xs handle FAIL msg => raise ABORT (err (xs, msg)); | 
| 101 | fun permissive scan xs = scan xs handle MORE _ => raise FAIL NONE | ABORT _ => raise FAIL NONE; | |
| 102 | fun strict scan xs = scan xs handle MORE _ => raise FAIL NONE; | |
| 103 | fun prompt str scan xs = scan xs handle MORE NONE => raise MORE (SOME str); | |
| 104 | fun error scan xs = scan xs handle ABORT msg => Library.error msg; | |
| 105 | ||
| 106 | fun catch scan xs = scan xs | |
| 107 | handle ABORT msg => raise Fail msg | |
| 38875 
c7a66b584147
tuned messages: discontinued spurious full-stops (messages are occasionally composed unexpectedly);
 wenzelm parents: 
37216diff
changeset | 108 | | FAIL msg => raise Fail (the_default "Syntax error" msg); | 
| 23699 | 109 | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 110 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 111 | (* scanner combinators *) | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 112 | |
| 19306 | 113 | fun (scan >> f) xs = scan xs |>> f; | 
| 14078 | 114 | |
| 19306 | 115 | fun (scan1 || scan2) xs = scan1 xs handle FAIL _ => scan2 xs; | 
| 14078 | 116 | |
| 19306 | 117 | fun (scan1 :-- scan2) xs = | 
| 14108 
eaf3c75f2c8e
Restored old (tail recursive!) version of repeat.
 berghofe parents: 
14078diff
changeset | 118 | let | 
| 19306 | 119 | val (x, ys) = scan1 xs; | 
| 120 | val (y, zs) = scan2 x ys; | |
| 121 | in ((x, y), zs) end; | |
| 14078 | 122 | |
| 19306 | 123 | fun (scan1 -- scan2) = scan1 :-- (fn _ => scan2); | 
| 24025 | 124 | fun (scan1 :|-- scan2) = scan1 :-- scan2 >> #2; | 
| 19306 | 125 | fun (scan1 |-- scan2) = scan1 -- scan2 >> #2; | 
| 126 | fun (scan1 --| scan2) = scan1 -- scan2 >> #1; | |
| 127 | fun (scan1 ^^ scan2) = scan1 -- scan2 >> op ^; | |
| 25999 | 128 | fun (scan1 ::: scan2) = scan1 -- scan2 >> op ::; | 
| 129 | fun (scan1 @@@ scan2) = scan1 -- scan2 >> op @; | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 130 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 131 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 132 | (* generic scanners *) | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 133 | |
| 15531 | 134 | fun fail _ = raise FAIL NONE; | 
| 135 | fun fail_with msg_of xs = raise FAIL (SOME (msg_of xs)); | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 136 | fun succeed y xs = (y, xs); | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 137 | |
| 15664 | 138 | fun some _ [] = raise MORE NONE | 
| 139 | | some f (x :: xs) = | |
| 140 | (case f x of SOME y => (y, xs) | _ => raise FAIL NONE); | |
| 141 | ||
| 15531 | 142 | fun one _ [] = raise MORE NONE | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 143 | | one pred (x :: xs) = | 
| 15531 | 144 | if pred x then (x, xs) else raise FAIL NONE; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 145 | |
| 19306 | 146 | fun $$ a = one (fn s: string => s = a); | 
| 147 | fun ~$$ a = one (fn s: string => s <> a); | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 148 | |
| 14833 | 149 | fun this ys xs = | 
| 14726 | 150 | let | 
| 151 | fun drop_prefix [] xs = xs | |
| 15531 | 152 | | drop_prefix (_ :: _) [] = raise MORE NONE | 
| 14726 | 153 | | drop_prefix (y :: ys) (x :: xs) = | 
| 19291 | 154 | if (y: string) = x then drop_prefix ys xs else raise FAIL NONE; | 
| 14726 | 155 | in (ys, drop_prefix ys xs) end; | 
| 156 | ||
| 40627 
becf5d5187cc
renamed raw "explode" function to "raw_explode" to emphasize its meaning;
 wenzelm parents: 
38875diff
changeset | 157 | fun this_string s = this (raw_explode s) >> K s; (*primitive string -- no symbols here!*) | 
| 14907 | 158 | |
| 21858 
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
 wenzelm parents: 
19473diff
changeset | 159 | fun many _ [] = raise MORE NONE | 
| 
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
 wenzelm parents: 
19473diff
changeset | 160 | | many pred (lst as x :: xs) = | 
| 
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
 wenzelm parents: 
19473diff
changeset | 161 | if pred x then apfst (cons x) (many pred xs) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 162 | else ([], lst); | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 163 | |
| 25999 | 164 | fun many1 pred = one pred ::: many pred; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 165 | |
| 15664 | 166 | fun optional scan def = scan || succeed def; | 
| 167 | fun option scan = (scan >> SOME) || succeed NONE; | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 168 | |
| 13795 | 169 | fun repeat scan = | 
| 15664 | 170 | let | 
| 171 | fun rep ys xs = | |
| 172 | (case (SOME (scan xs) handle FAIL _ => NONE) of | |
| 173 | NONE => (rev ys, xs) | |
| 174 | | SOME (y, xs') => rep (y :: ys) xs'); | |
| 14108 
eaf3c75f2c8e
Restored old (tail recursive!) version of repeat.
 berghofe parents: 
14078diff
changeset | 175 | in rep [] end; | 
| 13795 | 176 | |
| 25999 | 177 | fun repeat1 scan = scan ::: repeat scan; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 178 | |
| 23699 | 179 | fun single scan = scan >> (fn x => [x]); | 
| 180 | fun bulk scan = scan -- repeat (permissive scan) >> (op ::); | |
| 181 | ||
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 182 | fun max leq scan1 scan2 xs = | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 183 | (case (option scan1 xs, option scan2 xs) of | 
| 15531 | 184 | ((NONE, _), (NONE, _)) => raise FAIL NONE (*looses FAIL msg!*) | 
| 185 | | ((SOME tok1, xs'), (NONE, _)) => (tok1, xs') | |
| 186 | | ((NONE, _), (SOME tok2, xs')) => (tok2, xs') | |
| 187 | | ((SOME tok1, xs1'), (SOME tok2, xs2')) => | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 188 | if leq (tok2, tok1) then (tok1, xs1') else (tok2, xs2')); | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 189 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 190 | fun ahead scan xs = (fst (scan xs), xs); | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 191 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 192 | fun unless test scan = | 
| 15531 | 193 | ahead (option test) :-- (fn NONE => scan | _ => fail) >> #2; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 194 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 195 | fun first [] = fail | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 196 | | first (scan :: scans) = scan || first scans; | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 197 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 198 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 199 | (* state based scanners *) | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 200 | |
| 9122 | 201 | fun state (st, xs) = (st, (st, xs)); | 
| 202 | ||
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 203 | fun depend scan (st, xs) = | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 204 | let val ((st', y), xs') = scan st xs | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 205 | in (y, (st', xs')) end; | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 206 | |
| 15664 | 207 | fun peek scan = depend (fn st => scan st >> pair st); | 
| 208 | ||
| 209 | fun pass st scan xs = | |
| 210 | let val (y, (_, xs')) = scan (st, xs) | |
| 211 | in (y, xs') end; | |
| 212 | ||
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 213 | fun lift scan (st, xs) = | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 214 | let val (y, xs') = scan xs | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 215 | in (y, (st, xs')) end; | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 216 | |
| 15664 | 217 | fun unlift scan = pass () scan; | 
| 218 | ||
| 219 | ||
| 220 | (* trace input *) | |
| 221 | ||
| 23699 | 222 | fun trace scan xs = | 
| 223 | let val (y, xs') = scan xs | |
| 33957 | 224 | in ((y, take (length xs - length xs') xs), xs') end; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 225 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 226 | |
| 27731 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 227 | (* stopper *) | 
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 228 | |
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 229 | datatype 'a stopper = Stopper of ('a list -> 'a) * ('a -> bool);
 | 
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 230 | |
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 231 | fun stopper mk_stopper is_stopper = Stopper (mk_stopper, is_stopper); | 
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 232 | fun is_stopper (Stopper (_, is_stopper)) = is_stopper; | 
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 233 | |
| 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 234 | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 235 | (* finite scans *) | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 236 | |
| 27731 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 237 | fun finite' (Stopper (mk_stopper, is_stopper)) scan (state, input) = | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 238 | let | 
| 24595 | 239 | fun lost () = raise ABORT "Bad scanner: lost stopper of finite scan!"; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 240 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 241 | fun stop [] = lost () | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 242 | | stop lst = | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 243 | let val (xs, x) = split_last lst | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 244 | in if is_stopper x then ((), xs) else lost () end; | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 245 | in | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 246 | if exists is_stopper input then | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 247 | raise ABORT "Stopper may not occur in input of finite scan!" | 
| 27731 
a7444ded92cf
abstract type stopper, may depend on final input;
 wenzelm parents: 
25999diff
changeset | 248 | else (strict scan --| lift stop) (state, input @ [mk_stopper input]) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 249 | end; | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 250 | |
| 15664 | 251 | fun finite stopper scan = unlift (finite' stopper (lift scan)); | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 252 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 253 | fun read stopper scan xs = | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 254 | (case error (finite stopper (option scan)) xs of | 
| 15531 | 255 | (y as SOME _, []) => y | 
| 256 | | _ => NONE); | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 257 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 258 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 259 | (* infinite scans -- draining state-based source *) | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 260 | |
| 23699 | 261 | fun drain def_prompt get stopper scan ((state, xs), src) = | 
| 262 | (scan (state, xs), src) handle MORE prompt => | |
| 263 | (case get (the_default def_prompt prompt) src of | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 264 | ([], _) => (finite' stopper scan (state, xs), src) | 
| 23699 | 265 | | (xs', src') => drain def_prompt get stopper scan ((state, xs @ xs'), src')); | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 266 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 267 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 268 | |
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 269 | (** datatype lexicon -- position tree **) | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 270 | |
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 271 | datatype lexicon = Lexicon of (bool * lexicon) Symtab.table; | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 272 | |
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 273 | val empty_lexicon = Lexicon Symtab.empty; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 274 | |
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 275 | fun is_literal _ [] = false | 
| 32784 | 276 | | is_literal (Lexicon tab) (c :: cs) = | 
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 277 | (case Symtab.lookup tab c of | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 278 | SOME (tip, lex) => tip andalso null cs orelse is_literal lex cs | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 279 | | NONE => false); | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 280 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 281 | |
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 282 | (* scan longest match *) | 
| 27765 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 283 | |
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 284 | fun literal lexicon = | 
| 27765 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 285 | let | 
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 286 | fun finish (SOME (res, rest)) = (rev res, rest) | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 287 | | finish NONE = raise FAIL NONE; | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 288 | fun scan _ res (Lexicon tab) [] = if Symtab.is_empty tab then finish res else raise MORE NONE | 
| 32784 | 289 | | scan path res (Lexicon tab) (c :: cs) = | 
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 290 | (case Symtab.lookup tab (fst c) of | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 291 | SOME (tip, lex) => | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 292 | let val path' = c :: path | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 293 | in scan path' (if tip then SOME (path', cs) else res) lex cs end | 
| 27784 | 294 | | NONE => finish res); | 
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 295 | in scan [] NONE lexicon end; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 296 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 297 | |
| 27765 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 298 | (* build lexicons *) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 299 | |
| 27765 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 300 | fun extend_lexicon chrs lexicon = | 
| 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 301 | let | 
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 302 | fun ext [] lex = lex | 
| 32784 | 303 | | ext (c :: cs) (Lexicon tab) = | 
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 304 | (case Symtab.lookup tab c of | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 305 | SOME (tip, lex) => Lexicon (Symtab.update (c, (tip orelse null cs, ext cs lex)) tab) | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 306 | | NONE => Lexicon (Symtab.update (c, (null cs, ext cs empty_lexicon)) tab)); | 
| 27765 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 307 | in if is_literal lexicon chrs then lexicon else ext chrs lexicon end; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 308 | |
| 27765 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 309 | fun make_lexicon chrss = fold extend_lexicon chrss empty_lexicon; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 310 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 311 | |
| 27765 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 312 | (* merge lexicons *) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 313 | |
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 314 | fun dest path (Lexicon tab) = Symtab.fold (fn (d, (tip, lex)) => | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 315 | let | 
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 316 | val path' = d :: path; | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 317 | val content = dest path' lex; | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 318 | in append (if tip then rev path' :: content else content) end) tab []; | 
| 27765 
5df443dd9deb
reorganized lexicon: allow scanning of annotated symbols, tuned representation and interfaces;
 wenzelm parents: 
27731diff
changeset | 319 | |
| 27782 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 320 | val dest_lexicon = map implode o dest []; | 
| 
377810fd718e
datatype lexicon: alternative representation using nested Symtab.table;
 wenzelm parents: 
27765diff
changeset | 321 | fun merge_lexicons (lex1, lex2) = fold extend_lexicon (dest [] lex2) lex1; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 322 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 323 | end; | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 324 | |
| 37216 
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
 wenzelm parents: 
33957diff
changeset | 325 | structure Basic_Scan: BASIC_SCAN = Scan; | 
| 
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
 wenzelm parents: 
33957diff
changeset | 326 | open Basic_Scan; |