summaryrefslogtreecommitdiff
path: root/ppc.fun
diff options
context:
space:
mode:
authorVladimir Azarov <avm@intermediate-node.net>2025-05-20 01:15:06 +0200
committerVladimir Azarov <avm@intermediate-node.net>2025-05-20 01:15:06 +0200
commit2a1cfad37d5e87b2d7eb3c9da16db66364a9b9a3 (patch)
tree69bcd46d50cc0c2749fb9f30943fd917e55ed1e3 /ppc.fun
parentb8571d32ab934bf275878ff136487c8b5bc505b5 (diff)
#pragma support
Diffstat (limited to 'ppc.fun')
-rw-r--r--ppc.fun50
1 files changed, 29 insertions, 21 deletions
diff --git a/ppc.fun b/ppc.fun
index 23684ab..bb07107 100644
--- a/ppc.fun
+++ b/ppc.fun
@@ -820,25 +820,29 @@ struct
else
(not defined, "ifndef")
in
- dprintf ppc PDP T.S.Ppos ifPos `": #" `form `" " `id `" -> " B cond %;
+ dprintf ppc PDP T.S.Ppos ifPos `": #" `form `" "
+ `id `" -> " B cond `"\n"%;
(cond, ppc)
end
+ and skip ppc cl =
+ let
+ val (tk, _, ppc) = getTokenNoexpand ppc
+ in
+ case tk of
+ T.EOS => cl ()
+ | T.NewLine => ppc
+ | _ => skip ppc cl
+ end
+
and ifEval ifPos ppc =
let
- fun skip ppc =
- let
- val (tk, _, ppc) = getTokenNoexpand ppc
- in
- case tk of
- T.EOS => errorSpos ifPos `"unfinished #if condition" %
- | T.NewLine => ppc
- | _ => skip ppc
- end
+ val ppc =
+ skip ppc (fn () => errorSpos ifPos `"unfinished #if condition" %)
val cond = true
in
- dprintf ppc PDP T.S.Ppos ifPos `": #if -> " B cond `" (skipping)" %;
- (cond, skip ppc)
+ dprintf ppc PDP T.S.Ppos ifPos `": #if -> " B cond `" (skipping)";
+ (cond, ppc)
end
and handleIf (tk, ifPos) ppc =
@@ -864,7 +868,7 @@ struct
val (_, _, ppc) = getClassNoexpand ppc [Ctk T.NewLine]
val (prevVal, macros) = Tree.delete macroCompare (#macros ppc) id
in
- dprintf ppc PDP `"#undef " `id %;
+ dprintf ppc PDP `"#undef " `id `"\n" %;
case prevVal of
NONE => warning pos
`"#undef: no macro with provided name was defined" %
@@ -872,6 +876,16 @@ struct
updatePpc ppc s#macros macros %
end
+ and handleStray (tk, pos) _ = errorSpos pos `"stray " T.Ptk tk %
+
+ and handlePragma (_, pos) ppc = (
+ dprintf ppc PDP `"#pragma -> ignored\n";
+ skip ppc (fn () => errorSpos pos `"unfinished #pragma" %)
+ )
+
+ and ppcFallback (_, pos) _ =
+ errorSpos pos `"directive is not implemented" %
+
and handleRegularToken tk pos ppc =
let
fun checkAndMark (true, _, _) = (NONE, NONE)
@@ -899,11 +913,6 @@ struct
| _ => def ()
end
- and handleStray (tk, pos) _ = errorSpos pos `"stray " T.Ptk tk %
-
- and ppcFallback (_, pos) _ =
- errorSpos pos `"directive is not implemented" %
-
and handleToken tk pos ppc =
let
fun %tk = fn tk' => tk' = tk
@@ -919,7 +928,7 @@ struct
(%T.PpcEndif, handleStray),
(%T.PpcWarning, ppcFallback),
(%T.PpcError, ppcFallback),
- (%T.PpcPragma, ppcFallback)
+ (%T.PpcPragma, handlePragma)
]
in
case List.find (fn (f, _) => f tk) directiveTable of
@@ -979,6 +988,5 @@ struct
printf A2 debugPrint' startCache ppc F %
end
- fun getClass ppc clList =
- getClassGeneric clList getTokenSkipNL ppc
+ val getToken = getTokenSkipNL
end