This commit is contained in:
Dmitry Boulytchev 2018-05-25 09:53:10 +03:00
parent 57588f2605
commit 72c963f60f
2 changed files with 23 additions and 3 deletions

View file

@ -124,10 +124,24 @@ void Lprintf (char *s, ...) {
va_list args;
va_start (args, s);
vprintf (s, args);
vprintf (s, args); // vprintf (char *, va_list) <-> printf (char *, ...)
va_end (args);
}
void* Lstrcat (void *a, void *b) {
data *da = TO_DATA(a);
data *db = TO_DATA(b);
data *d = (data *) malloc (sizeof(int) + LEN(da->tag) + LEN(db->tag) + 1);
d->tag = LEN(da->tag) + LEN(db->tag);
strcpy (d->contents, da->contents);
strcat (d->contents, db->contents);
return d->contents;
}
void Lfprintf (FILE *f, char *s, ...) {
va_list args;

View file

@ -231,13 +231,19 @@ module Expr =
!(Ostap.Util.expr
(fun x -> x)
(Array.map (fun (a, s) -> a,
List.map (fun s -> ostap(- $(s)), (fun x y -> Binop (s, x, y))) s
List.map (fun s -> ostap(- $(s)),
(fun x y ->
match s with
"++" -> Call ("strcat", [x; y])
| _ -> Binop (s, x, y)
)
) s
)
[|
`Lefta, ["!!"];
`Lefta, ["&&"];
`Nona , ["=="; "!="; "<="; "<"; ">="; ">"];
`Lefta, ["+" ; "-"];
`Lefta, ["++"; "+" ; "-"];
`Lefta, ["*" ; "/"; "%"];
|]
)