/*-------------------------------------------------------------------------* * STRING_TO_NUMBER * * * *-------------------------------------------------------------------------*/ static Bool String_To_Number(char *str, WamWord number_word) { WamWord word; int stm; StmInf *pstm; Bool eof; Pl_Check_For_Un_Number(number_word); /* #if 0 since layout leading chars allowed in ISO cf. number_chars */ #if 0 if (!isdigit(*str) && *str != '-') { Pl_Set_Last_Syntax_Error("", 1, 1, "non numeric character"); goto err; } #endif stm = Pl_Add_Str_Stream(str, TERM_STREAM_ATOM); pstm = pl_stm_tbl[stm]; word = Pl_Read_Number(pstm); eof = (Pl_Stream_Peekc(pstm) == EOF); if (word != NOT_A_WAM_WORD && !eof) Pl_Set_Last_Syntax_Error(pl_atom_tbl[pstm->atom_file_name].name, pstm->line_count + 1, pstm->line_pos + 1, "non numeric character"); Pl_Delete_Str_Stream(stm); if (word == NOT_A_WAM_WORD || !eof) { #if 0 err: #endif Pl_Syntax_Error(Flag_Value(syntax_error)); return FALSE; } return Pl_Unify(word, number_word); }
/*-------------------------------------------------------------------------* * PL_EMIT_SYNTAX_ERROR * * * *-------------------------------------------------------------------------*/ void Pl_Emit_Syntax_Error(char *file_name, int err_line, int err_col, char *err_msg) { Pl_Set_Last_Syntax_Error(file_name, err_line, err_col, err_msg); Pl_Syntax_Error(Flag_Value(FLAG_SYNTAX_ERROR)); }