X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flexer.c;h=a3b43a96f63b33d0151c8efa32df3569ba64f018;hb=d4d9866bb2ec1797b8fb103e7144d0e9ffd1abff;hp=6bcb46eb97c88c71028f435f1dcd65fad254e320;hpb=4944c86a9318bc5b5578ab145a95c116ffd2c9fd;p=pspp-builds.git diff --git a/src/lexer.c b/src/lexer.c index 6bcb46eb..a3b43a96 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -18,6 +18,7 @@ 02111-1307, USA. */ #include +#include "lexer.h" #include #include #include @@ -29,12 +30,13 @@ #include "command.h" #include "error.h" #include "getline.h" -#include "lexer.h" #include "magic.h" #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. */ +double +lex_double (void) +{ + assert (lex_double_p ()); + return tokval; +} + /* Token matching functions. */