102 |
val context = AbsPath.relativeContext (AbsPath.dir group) |
val context = AbsPath.relativeContext (AbsPath.dir group) |
103 |
val filename = AbsPath.name group |
val filename = AbsPath.name group |
104 |
val _ = Say.vsay ["[scanning ", filename, "]\n"] |
val _ = Say.vsay ["[scanning ", filename, "]\n"] |
105 |
val stream = AbsPath.openTextIn group |
|
106 |
val source = S.newSource (filename, 1, stream, false, errcons) |
fun work stream = let |
107 |
|
val source = |
108 |
|
S.newSource (filename, 1, stream, false, errcons) |
109 |
val sourceMap = #sourceMap source |
val sourceMap = #sourceMap source |
110 |
val _ = GroupReg.register groupreg (group, source) |
val _ = GroupReg.register groupreg (group, source) |
111 |
|
|
121 |
* Errors are propagated by explicitly setting the |
* Errors are propagated by explicitly setting the |
122 |
* "anyErrors" flag of the parent group. *) |
* "anyErrors" flag of the parent group. *) |
123 |
fun recParse (p1, p2) p = let |
fun recParse (p1, p2) p = let |
124 |
val groupstack' = (group, (source, p1, p2)) :: groupstack |
val groupstack' = |
125 |
|
(group, (source, p1, p2)) :: groupstack |
126 |
val myErrorFlag = #anyErrors source |
val myErrorFlag = #anyErrors source |
127 |
in |
in |
128 |
case mparse (p, groupstack', myErrorFlag, staball) of |
case mparse (p, groupstack', myErrorFlag, staball) of |
158 |
end |
end |
159 |
(* handling strings *) |
(* handling strings *) |
160 |
fun newS pos = |
fun newS pos = |
161 |
(instring := true; curstring := []; startpos := pos) |
(instring := true; |
162 |
|
curstring := []; |
163 |
|
startpos := pos) |
164 |
fun addS c = curstring := c :: !curstring |
fun addS c = curstring := c :: !curstring |
165 |
fun addSC (s, offs) = |
fun addSC (s, offs) = |
166 |
addS (chr (ord (String.sub (s, 2)) - offs)) |
addS (chr (ord (String.sub (s, 2)) - offs)) |
196 |
fun sep c = c = #"#" orelse Char.isSpace c |
fun sep c = c = #"#" orelse Char.isSpace c |
197 |
fun cvt s = getOpt (Int.fromString s, 0) |
fun cvt s = getOpt (Int.fromString s, 0) |
198 |
fun r (line, col, file) = SM.resynch sourceMap |
fun r (line, col, file) = SM.resynch sourceMap |
199 |
(p, { fileName = file, line = line, column = col }) |
(p, { fileName = file, |
200 |
|
line = line, column = col }) |
201 |
in |
in |
202 |
case String.tokens sep t of |
case String.tokens sep t of |
203 |
[_, line] => |
[_, line] => |
233 |
(group, context, error, recParse, |
(group, context, error, recParse, |
234 |
doMember, ginfo)) |
doMember, ginfo)) |
235 |
in |
in |
|
TextIO.closeIn stream; |
|
236 |
if !(#anyErrors source) then NONE |
if !(#anyErrors source) then NONE |
|
else if stabthis then stabilize parseResult |
|
237 |
else SOME parseResult |
else SOME parseResult |
238 |
end |
end |
239 |
|
val pro = |
240 |
|
SafeIO.perform { openIt = |
241 |
|
fn () => AbsPath.openTextIn group, |
242 |
|
closeIt = TextIO.closeIn, |
243 |
|
work = work, |
244 |
|
cleanup = fn () => () } |
245 |
|
in |
246 |
|
case pro of |
247 |
|
NONE => NONE |
248 |
|
| SOME pr => |
249 |
|
if stabthis then stabilize pr |
250 |
|
else SOME pr |
251 |
|
end |
252 |
handle LrParser.ParseError => NONE |
handle LrParser.ParseError => NONE |
253 |
in |
in |
254 |
case findCycle (groupstack, []) of |
case findCycle (groupstack, []) of |