/* Returns true if the current token is a number. */
bool
-lex_is_number (struct lexer *lexer)
+lex_is_number (const struct lexer *lexer)
{
return lex_next_is_number (lexer, 0);
}
/* Returns true if the current token is a string. */
bool
-lex_is_string (struct lexer *lexer)
+lex_is_string (const struct lexer *lexer)
{
return lex_next_is_string (lexer, 0);
}
/* Returns the value of the current token, which must be a
floating point number. */
double
-lex_number (struct lexer *lexer)
+lex_number (const struct lexer *lexer)
{
return lex_next_number (lexer, 0);
}
/* Returns true iff the current token is an integer. */
bool
-lex_is_integer (struct lexer *lexer)
+lex_is_integer (const struct lexer *lexer)
{
return lex_next_is_integer (lexer, 0);
}
/* Returns the value of the current token, which must be an
integer. */
long
-lex_integer (struct lexer *lexer)
+lex_integer (const struct lexer *lexer)
{
return lex_next_integer (lexer, 0);
}
/* Returns true if the token N ahead of the current token is a number. */
bool
-lex_next_is_number (struct lexer *lexer, int n)
+lex_next_is_number (const struct lexer *lexer, int n)
{
enum token_type next_token = lex_next_token (lexer, n);
return next_token == T_POS_NUM || next_token == T_NEG_NUM;
/* Returns true if the token N ahead of the current token is a string. */
bool
-lex_next_is_string (struct lexer *lexer, int n)
+lex_next_is_string (const struct lexer *lexer, int n)
{
return lex_next_token (lexer, n) == T_STRING;
}
/* Returns the value of the token N ahead of the current token, which must be a
floating point number. */
double
-lex_next_number (struct lexer *lexer, int n)
+lex_next_number (const struct lexer *lexer, int n)
{
assert (lex_next_is_number (lexer, n));
return lex_next_tokval (lexer, n);
/* Returns true if the token N ahead of the current token is an integer. */
bool
-lex_next_is_integer (struct lexer *lexer, int n)
+lex_next_is_integer (const struct lexer *lexer, int n)
{
double value;
/* Returns the value of the token N ahead of the current token, which must be
an integer. */
long
-lex_next_integer (struct lexer *lexer, int n)
+lex_next_integer (const struct lexer *lexer, int n)
{
assert (lex_next_is_integer (lexer, n));
return lex_next_tokval (lexer, n);
void lex_get (struct lexer *);
/* Token testing functions. */
-bool lex_is_number (struct lexer *);
-double lex_number (struct lexer *);
-bool lex_is_integer (struct lexer *);
-long lex_integer (struct lexer *);
-bool lex_is_string (struct lexer *);
+bool lex_is_number (const struct lexer *);
+double lex_number (const struct lexer *);
+bool lex_is_integer (const struct lexer *);
+long lex_integer (const struct lexer *);
+bool lex_is_string (const struct lexer *);
/* Token testing functions with lookahead. */
-bool lex_next_is_number (struct lexer *, int n);
-double lex_next_number (struct lexer *, int n);
-bool lex_next_is_integer (struct lexer *, int n);
-long lex_next_integer (struct lexer *, int n);
-bool lex_next_is_string (struct lexer *, int n);
+bool lex_next_is_number (const struct lexer *, int n);
+double lex_next_number (const struct lexer *, int n);
+bool lex_next_is_integer (const struct lexer *, int n);
+long lex_next_integer (const struct lexer *, int n);
+bool lex_next_is_string (const struct lexer *, int n);
/* Token matching functions. */
bool lex_match (struct lexer *, enum token_type);