summaryrefslogtreecommitdiff
path: root/ppc.fun
diff options
context:
space:
mode:
Diffstat (limited to 'ppc.fun')
-rw-r--r--ppc.fun41
1 files changed, 25 insertions, 16 deletions
diff --git a/ppc.fun b/ppc.fun
index 0aae7b6..23684ab 100644
--- a/ppc.fun
+++ b/ppc.fun
@@ -579,15 +579,26 @@ struct
(tk, pos, ppc)
end
- fun parseArg ppc acc =
+ fun parseArg level ppc acc =
let
val (tk, pos, ppc) = getTokenRestricted ppc
+ fun continue dx = parseArg (level + dx) ppc ((tk, pos) :: acc)
in
case tk of
T.EOS => error mPos `"unfinished argument list" %
- | T.Coma => (true, rev acc, ppc)
- | T.RParen => (false, rev acc, ppc)
- | _ => parseArg ppc ((tk, pos) :: acc)
+ | T.LParen => continue 1
+ | T.Coma =>
+ if level > 0 then
+ continue 0
+ else
+ (true, rev acc, ppc)
+ | T.RParen =>
+ if level > 0 then
+ continue (~1)
+ else
+ (false, rev acc, ppc)
+ | T.NewLine => parseArg level ppc acc
+ | _ => continue 0
end
fun parseArgs ppc params acc =
@@ -595,7 +606,7 @@ struct
fun bind _ [] = error mPos `"too many arguments" %
| bind body (param :: params) = ((param, body), params)
- val (continue, arg, ppc) = parseArg ppc []
+ val (continue, arg, ppc) = parseArg 0 ppc []
val (bindedParam, otherParams) = bind arg params
in
if continue then
@@ -941,6 +952,15 @@ struct
updatePpc P u#buffer (updateH head) %
end
+ and getTokenSkipNL ppc =
+ let
+ val (tk, pos, ppc) = getToken ppc
+ in
+ case tk of
+ T.NewLine => getTokenSkipNL ppc
+ | _ => (tk, pos, ppc)
+ end
+
fun debugPrint' (out, cache, ppc) =
let
val (tk, pos, ppc) = getToken ppc
@@ -960,16 +980,5 @@ struct
end
fun getClass ppc clList =
- let
- fun getTokenSkipNL ppc =
- let
- val (tk, pos, ppc) = getToken ppc
- in
- case tk of
- T.NewLine => getTokenSkipNL ppc
- | _ => (tk, pos, ppc)
- end
- in
getClassGeneric clList getTokenSkipNL ppc
- end
end