Skip to content

Commit

Permalink
potion #9 for p2: save and restore the overwritten P fields.
Browse files Browse the repository at this point in the history
source, yypos, input. skip pbuf
  • Loading branch information
Reini Urban committed Sep 16, 2013
1 parent d23c65c commit e97da72
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions syn/syntax-p5.y
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ arg2 = !arg2-sigil t:arg2-type m:arg-modifier n:arg2-name { SRC_TPL3(n,t,m) }

PN p2_parse(Potion *P, PN code, char *filename) {
GREG *G = YY_NAME(parse_new)(P);
int oldyypos = P->yypos;
PN oldinput = P->input;
PN oldsource = P->source;
P->yypos = 0;
P->input = code;
P->source = PN_NIL;
Expand All @@ -533,7 +536,9 @@ PN p2_parse(Potion *P, PN code, char *filename) {
YY_NAME(parse_free)(G);

code = P->source;
P->source = PN_NIL;
P->source = oldsource;
P->yypos = oldyypos;
P->input = oldinput;
return code;
}

Expand All @@ -544,6 +549,9 @@ PN potion_sig(Potion *P, char *fmt) {
if (fmt[0] == '\0') return PN_FALSE;
GREG *G = YY_NAME(parse_new)(P);
int oldyypos = P->yypos;
PN oldinput = P->input;
PN oldsource = P->source;
P->yypos = 0;
P->input = potion_byte_str(P, fmt);
P->source = out = PN_TUP0();
Expand All @@ -555,7 +563,9 @@ PN potion_sig(Potion *P, char *fmt) {
YY_NAME(parse_free)(G);
out = P->source;
P->source = PN_NIL;
P->source = oldsource;
P->yypos = oldyypos;
P->input = oldinput;
return out;
}

Expand All @@ -565,6 +575,9 @@ PN p2_sig(Potion *P, char *fmt) {
if (fmt[0] == '\0') return PN_FALSE; // empty signature, no args
GREG *G = YY_NAME(parse_new)(P);
int oldyypos = P->yypos;
PN oldinput = P->input;
PN oldsource = P->source;
P->yypos = 0;
P->input = potion_byte_str(P, fmt);
P->source = out = PN_TUP0();
Expand All @@ -576,7 +589,9 @@ PN p2_sig(Potion *P, char *fmt) {
YY_NAME(parse_free)(G);
out = P->source;
P->source = PN_NIL;
P->source = oldsource;
P->yypos = oldyypos;
P->input = oldinput;
return out;
}

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,5 @@ if [ -z `grep DDEBUG config.inc` ]; then
time bin/p2 $f 2>&1 | tee -a $log
done
fi

export LD_LIBRARY_PATH="$old_LIBRARY_PATH"

0 comments on commit e97da72

Please sign in to comment.