X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=src%2Flexer.c;h=94793bfb9557d4d0191b411c93405bc09fcd98e2;hb=8b811199c8a79dba237254527012b43773e60975;hp=edcc5a2ae381498d901ae1589c4daf6292715d2f;hpb=3a7fba81ceae5b049d0f7d671e9e3c3c43bbf703;p=pspp diff --git a/src/lexer.c b/src/lexer.c index edcc5a2ae3..94793bfb95 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -34,7 +34,9 @@ #include "settings.h" #include "str.h" -/*#define DUMP_TOKENS 1*/ +/* +#define DUMP_TOKENS 1 +*/ /* Global variables. */ @@ -159,6 +161,7 @@ lex_get (void) } } + /* Actually parse the token. */ cp = prog; ds_clear (&tokstr); @@ -409,6 +412,23 @@ lex_integer (void) assert (lex_integer_p ()); return tokval; } +/* Returns nonzero if the current token is an floating point. */ +int +lex_double_p (void) +{ + return ( token == T_NUM + && tokval != NOT_DOUBLE ); +} + +/* Returns the value of the current token, which must be a + floating point number. */ +long +lex_double (void) +{ + assert (lex_double_p ()); + return tokval; +} + /* Token matching functions. */