mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Pre-HW12
This commit is contained in:
parent
57588f2605
commit
72c963f60f
2 changed files with 23 additions and 3 deletions
|
|
@ -124,10 +124,24 @@ void Lprintf (char *s, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
va_start (args, s);
|
va_start (args, s);
|
||||||
vprintf (s, args);
|
vprintf (s, args); // vprintf (char *, va_list) <-> printf (char *, ...)
|
||||||
va_end (args);
|
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, ...) {
|
void Lfprintf (FILE *f, char *s, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -231,13 +231,19 @@ module Expr =
|
||||||
!(Ostap.Util.expr
|
!(Ostap.Util.expr
|
||||||
(fun x -> x)
|
(fun x -> x)
|
||||||
(Array.map (fun (a, s) -> a,
|
(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, ["!!"];
|
||||||
`Lefta, ["&&"];
|
`Lefta, ["&&"];
|
||||||
`Nona , ["=="; "!="; "<="; "<"; ">="; ">"];
|
`Nona , ["=="; "!="; "<="; "<"; ">="; ">"];
|
||||||
`Lefta, ["+" ; "-"];
|
`Lefta, ["++"; "+" ; "-"];
|
||||||
`Lefta, ["*" ; "/"; "%"];
|
`Lefta, ["*" ; "/"; "%"];
|
||||||
|]
|
|]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue