- switch (*lexer->prog)
- {
- case '-': case '.':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- {
- char *tail;
-
- /* `-' can introduce a negative number, or it can be a
- token by itself. If it is not followed by a digit or a
- decimal point, it is definitely not a number.
- Otherwise, it might be either, but most of the time we
- want it as a number. When the syntax calls for a `-'
- token, lex_negative_to_dash() must be used to break
- negative numbers into two tokens. */
- if (*lexer->prog == '-')
- {
- ds_put_char (&lexer->tokstr, *lexer->prog++);
- while (c_isspace ((unsigned char) *lexer->prog))
- lexer->prog++;
-
- if (!c_isdigit ((unsigned char) *lexer->prog) && *lexer->prog != '.')
- {
- lexer->token = '-';
- break;
- }
- lexer->token = T_NEG_NUM;
- }
- else
- lexer->token = T_POS_NUM;
-
- /* Parse the number, copying it into tokstr. */
- while (c_isdigit ((unsigned char) *lexer->prog))
- ds_put_char (&lexer->tokstr, *lexer->prog++);
- if (*lexer->prog == '.')
- {
- ds_put_char (&lexer->tokstr, *lexer->prog++);
- while (c_isdigit ((unsigned char) *lexer->prog))
- ds_put_char (&lexer->tokstr, *lexer->prog++);
- }
- if (*lexer->prog == 'e' || *lexer->prog == 'E')
- {
- ds_put_char (&lexer->tokstr, *lexer->prog++);
- if (*lexer->prog == '+' || *lexer->prog == '-')
- ds_put_char (&lexer->tokstr, *lexer->prog++);
- while (c_isdigit ((unsigned char) *lexer->prog))
- ds_put_char (&lexer->tokstr, *lexer->prog++);
- }
-
- /* Parse as floating point. */
- lexer->tokval = c_strtod (ds_cstr (&lexer->tokstr), &tail);
- if (*tail)
- {
- msg (SE, _("%s does not form a valid number."),
- ds_cstr (&lexer->tokstr));
- lexer->tokval = 0.0;
-
- ds_clear (&lexer->tokstr);
- ds_put_char (&lexer->tokstr, '0');
- }
-
- break;
- }
-
- case '\'': case '"':
- lexer->token = parse_string (lexer, CHARACTER_STRING);
- break;
-
- case '(': case ')': case ',': case '=': case '+': case '/':
- case '[': case ']':
- lexer->token = *lexer->prog++;
- break;
-
- case '*':
- if (*++lexer->prog == '*')
- {
- lexer->prog++;
- lexer->token = T_EXP;
- }
- else
- lexer->token = '*';
- break;
-
- case '<':
- if (*++lexer->prog == '=')
- {
- lexer->prog++;
- lexer->token = T_LE;
- }
- else if (*lexer->prog == '>')
- {
- lexer->prog++;
- lexer->token = T_NE;
- }
- else
- lexer->token = T_LT;
- break;
-
- case '>':
- if (*++lexer->prog == '=')
- {
- lexer->prog++;
- lexer->token = T_GE;
- }
- else
- lexer->token = T_GT;
- break;
-
- case '~':
- if (*++lexer->prog == '=')
- {
- lexer->prog++;
- lexer->token = T_NE;
- }
- else
- lexer->token = T_NOT;
- break;
-
- case '&':
- lexer->prog++;
- lexer->token = T_AND;
- break;
-
- case '|':
- lexer->prog++;
- lexer->token = T_OR;
- break;
-
- case 'b': case 'B':
- if (lexer->prog[1] == '\'' || lexer->prog[1] == '"')
- lexer->token = parse_string (lexer, BINARY_STRING);
- else
- lexer->token = parse_id (lexer);
- break;