reformatting

This commit is contained in:
Vítor Santos Costa 2016-02-14 04:15:28 +00:00
parent ae65bb0265
commit 0a9f37710c

View File

@ -182,9 +182,8 @@ static int parse_quasi_quotations(ReadData _PL_rd ARG_LD) {
#endif /*O_QUASIQUOTATIONS*/ #endif /*O_QUASIQUOTATIONS*/
#define READ_DEFS() \ #define READ_DEFS() \
PAR("comments", list_filler, READ_COMMENTS),\ PAR("comments", list_filler, READ_COMMENTS), \
PAR("module", isatom, READ_MODULE), \ PAR("module", isatom, READ_MODULE), PAR("priority", nat, READ_PRIORITY), \
PAR("priority", nat, READ_PRIORITY), \
PAR("quasi_quotations", filler, READ_QUASI_QUOTATIONS), \ PAR("quasi_quotations", filler, READ_QUASI_QUOTATIONS), \
PAR("term_position", filler, READ_TERM_POSITION), \ PAR("term_position", filler, READ_TERM_POSITION), \
PAR("syntax_errors", isatom, READ_SYNTAX_ERRORS), \ PAR("syntax_errors", isatom, READ_SYNTAX_ERRORS), \
@ -524,9 +523,7 @@ static void reset_regs(TokEntry *tokstart, FEnv *fe) {
POPFET(qq); POPFET(qq);
} }
static Term static Term get_variables(FEnv *fe, TokEntry *tokstart) {
get_variables(FEnv *fe, TokEntry *tokstart)
{
Term v; Term v;
if (fe->vp) { if (fe->vp) {
while (true) { while (true) {
@ -545,10 +542,7 @@ get_variables(FEnv *fe, TokEntry *tokstart)
return 0; return 0;
} }
static Term get_varnames(FEnv *fe, TokEntry *tokstart) {
static Term
get_varnames(FEnv *fe, TokEntry *tokstart)
{
Term v; Term v;
if (fe->np) { if (fe->np) {
while (true) { while (true) {
@ -567,10 +561,7 @@ get_varnames(FEnv *fe, TokEntry *tokstart)
return 0; return 0;
} }
static Term get_singletons(FEnv *fe, TokEntry *tokstart) {
static Term
get_singletons(FEnv *fe, TokEntry *tokstart)
{
Term v; Term v;
if (fe->sp) { if (fe->sp) {
while (TRUE) { while (TRUE) {
@ -587,9 +578,7 @@ get_singletons(FEnv *fe, TokEntry *tokstart)
return 0; return 0;
} }
static void static void warn_singletons(FEnv *fe, TokEntry *tokstart) {
warn_singletons(FEnv *fe, TokEntry *tokstart)
{
Term v; Term v;
fe->sp = TermNil; fe->sp = TermNil;
v = get_singletons(fe, tokstart); v = get_singletons(fe, tokstart);
@ -610,10 +599,7 @@ warn_singletons(FEnv *fe, TokEntry *tokstart)
} }
} }
static Term get_stream_position(FEnv *fe, TokEntry *tokstart) {
static Term
get_stream_position(FEnv *fe, TokEntry *tokstart)
{
Term v; Term v;
if (fe->tp) { if (fe->tp) {
while (true) { while (true) {
@ -630,8 +616,6 @@ get_stream_position(FEnv *fe, TokEntry *tokstart)
return 0; return 0;
} }
static bool complete_processing(FEnv *fe, TokEntry *tokstart) { static bool complete_processing(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS CACHE_REGS
Term v1, v2, v3, vc, tp; Term v1, v2, v3, vc, tp;
@ -656,23 +640,21 @@ static bool complete_processing(FEnv *fe, TokEntry *tokstart) {
else else
vc = 0L; vc = 0L;
if (fe->t && fe->tp) if (fe->t && fe->tp)
tp = get_stream_position(fe, tokstart ); tp = get_stream_position(fe, tokstart);
else else
tp = 0L; tp = 0L;
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable); Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
// trail must be ok by now.] // trail must be ok by now.]
if ( ( !v1 || Yap_unify(v1, fe->vp) ) && if (fe->t) {
( !v2 || Yap_unify(v2, fe->np)) && return (!v1 || Yap_unify(v1, fe->vp)) && (!v2 || Yap_unify(v2, fe->np)) &&
( !v3 || Yap_unify(v3, fe->sp)) && (!v3 || Yap_unify(v3, fe->sp)) && (!tp || Yap_unify(tp, fe->tp)) &&
( !tp || Yap_unify(tp, fe->tp)) && (!vc || Yap_unify(vc, fe->tcomms));
( !vc || Yap_unify(vc, fe->tcomms))) }
return fe->t; return true;
return 0;
} }
static bool complete_clause_processing(FEnv *fe, TokEntry static bool complete_clause_processing(FEnv *fe, TokEntry *tokstart) {
*tokstart) {
CACHE_REGS CACHE_REGS
Term v_vp, v_vnames, v_comments, v_pos; Term v_vp, v_vnames, v_comments, v_pos;
@ -695,18 +677,19 @@ static bool complete_clause_processing(FEnv *fe, TokEntry
else else
v_comments = 0L; v_comments = 0L;
if (fe->t && fe->tp) if (fe->t && fe->tp)
v_pos = get_stream_position(fe, tokstart ); v_pos = get_stream_position(fe, tokstart);
else else
v_pos = 0L; v_pos = 0L;
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable); Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
// trail must be ok by now.] // trail must be ok by now.]
if ( ( !v_vp || Yap_unify(v_vp, fe->vp) ) && if (fe->t) {
( !v_vnames || Yap_unify(v_vnames, fe->np)) && return (!v_vp || Yap_unify(v_vp, fe->vp)) &&
( !v_pos || Yap_unify(v_pos, fe->tp)) && (!v_vnames || Yap_unify(v_vnames, fe->np)) &&
( !v_comments || Yap_unify(v_comments, fe->tcomms))) (!v_pos || Yap_unify(v_pos, fe->tp)) &&
return fe->t; (!v_comments || Yap_unify(v_comments, fe->tcomms));
return 0; }
return true;
} }
static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream, static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream,
@ -780,7 +763,7 @@ static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream,
fe->args = setReadEnv(opts, fe, re, inp_stream); fe->args = setReadEnv(opts, fe, re, inp_stream);
} }
if (fe->args == NULL) { if (fe->args == NULL) {
if (LOCAL_Error_TYPE == DOMAIN_ERROR_OUT_OF_RANGE) if (LOCAL_Error_TYPE == DOMAIN_ERROR_READ_OPTION)
LOCAL_Error_TYPE = DOMAIN_ERROR_READ_OPTION; LOCAL_Error_TYPE = DOMAIN_ERROR_READ_OPTION;
if (LOCAL_Error_TYPE) if (LOCAL_Error_TYPE)
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, NULL); Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, NULL);
@ -813,8 +796,8 @@ static parser_state_t scan(REnv *re, FEnv *fe, int inp_stream) {
return YAP_PARSING; return YAP_PARSING;
} }
if (LOCAL_tokptr->Tok == eot_tok && LOCAL_tokptr->TokInfo == TermNl) { if (LOCAL_tokptr->Tok == eot_tok && LOCAL_tokptr->TokInfo == TermNl) {
char *out = malloc( strlen("Empty clause" + 1 ) ); char *out = malloc(strlen("Empty clause" + 1));
strcpy( out, "Empty clause" ); strcpy(out, "Empty clause");
LOCAL_ErrorMessage = out; LOCAL_ErrorMessage = out;
LOCAL_Error_TYPE = SYNTAX_ERROR; LOCAL_Error_TYPE = SYNTAX_ERROR;
LOCAL_Error_Term = TermEof; LOCAL_Error_Term = TermEof;
@ -940,6 +923,8 @@ Term Yap_read_term(int inp_stream, Term opts, int nargs) {
switch (state) { switch (state) {
case YAP_START_PARSING: case YAP_START_PARSING:
state = initParser(opts, &fe, &re, inp_stream, nargs); state = initParser(opts, &fe, &re, inp_stream, nargs);
if (state == YAP_PARSING_FINISHED)
return 0;
break; break;
case YAP_SCANNING: case YAP_SCANNING:
state = scan(&re, &fe, inp_stream); state = scan(&re, &fe, inp_stream);
@ -953,8 +938,7 @@ Term Yap_read_term(int inp_stream, Term opts, int nargs) {
case YAP_PARSING_ERROR: case YAP_PARSING_ERROR:
state = parseError(&re, &fe, inp_stream); state = parseError(&re, &fe, inp_stream);
break; break;
case YAP_PARSING_FINISHED: case YAP_PARSING_FINISHED: {
{
CACHE_REGS CACHE_REGS
bool done; bool done;
if (fe.reading_clause) if (fe.reading_clause)
@ -996,7 +980,6 @@ static Int read_term(
inp_stream = Yap_CheckTextStream(ARG1, Input_Stream_f, "read/3"); inp_stream = Yap_CheckTextStream(ARG1, Input_Stream_f, "read/3");
if (inp_stream == -1) { if (inp_stream == -1) {
return (FALSE); return (FALSE);
} }
out = Yap_read_term(inp_stream, ARG3, 3); out = Yap_read_term(inp_stream, ARG3, 3);
UNLOCK(GLOBAL_Stream[inp_stream].streamlock); UNLOCK(GLOBAL_Stream[inp_stream].streamlock);
@ -1105,7 +1088,6 @@ static Int read_clause2(USES_REGS1) {
return rc && Yap_unify(tf, rc); return rc && Yap_unify(tf, rc);
} }
/** /**
* @pred read_clause( +_Stream_, -_Clause_, ?_Opts) is det * @pred read_clause( +_Stream_, -_Clause_, ?_Opts) is det
* *
@ -1144,7 +1126,6 @@ static Int read_clause(
return out && Yap_unify(tf, out); return out && Yap_unify(tf, out);
} }
/** /**
* @pred source_location( - _File_ , _Line_ ) * @pred source_location( - _File_ , _Line_ )
* *
@ -1299,8 +1280,6 @@ Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, int prio,
return rval; return rval;
} }
/** /**
* @pred read_term_from_atom( +_Atom_ , - _T_ , + _VarNames_ * @pred read_term_from_atom( +_Atom_ , - _T_ , + _VarNames_
* *
@ -1457,7 +1436,6 @@ static Term readFromBuffer(const char *s, Term opts) {
return rval; return rval;
} }
/** /**
* @pred read_term_from_string( +_String_ , - _T_ , + _Options_ * @pred read_term_from_string( +_String_ , - _T_ , + _Options_
* *