parser should parse +inf,-inf,+nan,-nan as floating point numbers
write should write inf as +inf and nan as +nan git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@92 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
54e9dc271d
commit
7d50fd267d
31
C/parser.c
31
C/parser.c
@ -343,6 +343,14 @@ ParseList(void)
|
||||
return (t);
|
||||
}
|
||||
|
||||
#ifndef INFINITY
|
||||
#define INFINITY (1.0/0.0)
|
||||
#endif
|
||||
|
||||
#ifndef NAN
|
||||
#define NAN (0.0/0.0)
|
||||
#endif
|
||||
|
||||
static Term
|
||||
ParseTerm(int prio)
|
||||
{
|
||||
@ -387,6 +395,29 @@ ParseTerm(int prio)
|
||||
NextToken;
|
||||
break;
|
||||
}
|
||||
} else if (tokptr->Tok == Name_tok) {
|
||||
Atom at = (Atom)tokptr->TokInfo;
|
||||
if ((Atom)t == AtomPlus) {
|
||||
if (at == AtomInf) {
|
||||
t = MkFloatTerm(INFINITY);
|
||||
NextToken;
|
||||
break;
|
||||
} else if (at == AtomNan) {
|
||||
t = MkFloatTerm(NAN);
|
||||
NextToken;
|
||||
break;
|
||||
}
|
||||
} else if ((Atom)t == AtomMinus) {
|
||||
if (at == AtomInf) {
|
||||
t = MkFloatTerm(-INFINITY);
|
||||
NextToken;
|
||||
break;
|
||||
} else if (at == AtomNan) {
|
||||
t = MkFloatTerm(NAN);
|
||||
NextToken;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (opprio <= prio) {
|
||||
/* try to parse as a prefix operator */
|
||||
|
Reference in New Issue
Block a user