Skip to content

Commit

Permalink
thread safe readparse
Browse files Browse the repository at this point in the history
  • Loading branch information
sasagawa888 committed Jan 3, 2025
1 parent 0e1b4a9 commit a1c033e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ int b_read(int arglist, int rest, int th)
input_stream = GET_CAR(arg1);
repl_flag = 0;

temp = variable_to_call(readparse());
temp = variable_to_call(readparse(th));
res = unify(arg2, temp, th);
input_stream = save1;
repl_flag = save2;
Expand Down Expand Up @@ -3329,7 +3329,7 @@ int b_string_term(int arglist, int rest, int th)
bridge[l + 1] = 0;
read_string_term(0); //initilize
bridge_flag = 1;
res = readparse();
res = readparse(th);
bridge_flag = 0;
if (unify(arg2, res, th) == YES)
return (prove_all(rest, sp[th], th));
Expand Down Expand Up @@ -3758,7 +3758,7 @@ int b_break(int arglist, int rest, int th)
while (1) {
printf("?= ");
fflush(stdout);
query_break(variable_to_call(readparse()), th);
query_break(variable_to_call(readparse(th)), th);
fflush(stdout);
}
} else if (ret == 1) {
Expand Down
2 changes: 1 addition & 1 deletion extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ int str_to_pred(int x)
memset(bridge, '\0', sizeof(bridge));
strcpy(bridge, GET_NAME(x));
read_string_term(0);
res = variable_to_call(readparse());
res = variable_to_call(readparse(0));
memset(bridge, 0, sizeof(bridge));
bridge_flag = 0;
return (res);
Expand Down
6 changes: 3 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ int main(int argc, char *argv[])
init_repl();
printf("?- ");
fflush(stdout);
input = variable_to_call(readparse());
input = variable_to_call(readparse(0));
if (!repl_flag)
clear_input_buffer();
query(input, 0);
Expand Down Expand Up @@ -1018,7 +1018,7 @@ void debugger(int goal, int bindings, int rest)

printf("- ");
fflush(stdout);
read = variable_to_call(readparse());
read = variable_to_call(readparse(0));
if (read == FEND)
goto break_exit;
query(read, 0);
Expand Down Expand Up @@ -1097,7 +1097,7 @@ void debugger(int goal, int bindings, int rest)
case '@':
printf("?- ");
fflush(stdout);
read = variable_to_call(readparse());
read = variable_to_call(readparse(0));
query(read, 0);
fflush(stdout);
break;
Expand Down
2 changes: 1 addition & 1 deletion npl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ int prove(int goal, int bindings, int rest, int th);
int prove_all(int goals, int bindings, int th);
int quoted_option_p(int x);
int quotient(int x, int y, int th);
int readparse(void);
int readparse(int th);
int readitem(int th);
int readitem1(int th);
int readcurl(int th);
Expand Down
6 changes: 3 additions & 3 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

//#define CHECK 1 //for parser debug check

int readparse(void)
int readparse(int th)
{
int res;

paren_nest = 0;
res = parser(NIL, NIL, NIL, NIL, 0, 0, 0);
res = parser(NIL, NIL, NIL, NIL, 0, 0, th);
if (paren_nest != 0)
error(SYNTAX_ERR, "extra paren ", NIL,0);
error(SYNTAX_ERR, "extra paren ", NIL,th);

return (res);
}
Expand Down

0 comments on commit a1c033e

Please sign in to comment.