The lexer has this function, so we might as well use it consistently.
count = parse_ids (lexer, dict, macro, block->pool);
else if (lex_is_number (lexer))
count = parse_numbers (lexer, macro, block->pool);
- else if (lex_token (lexer) == T_STRING)
+ else if (lex_is_string (lexer))
count = parse_strings (lexer, macro, block->pool);
else
{
{
char *string;
- if (lex_token (lexer) != T_STRING)
+ if (!lex_force_string (lexer))
{
msg (SE, _("String expected."));
return 0;
if (lex_match_id (lexer, "TAB"))
delim = '\t';
- else if (lex_token (lexer) == T_STRING
+ else if (lex_is_string (lexer)
&& ds_length (lex_tokstr (lexer)) == 1)
{
delim = ds_first (lex_tokstr (lexer));
handle = fh_inline_file ();
else
{
- if (lex_token (lexer) != T_ID && lex_token (lexer) != T_STRING)
+ if (lex_token (lexer) != T_ID && !lex_is_string (lexer))
{
lex_error (lexer, _("expecting a file name or handle name"));
return NULL;
{
lex_match (lexer, '/');
- if (lex_match_id (lexer, "FILE") || lex_token (lexer) == T_STRING)
+ if (lex_match_id (lexer, "FILE") || lex_is_string (lexer))
{
lex_match (lexer, '=');
if (!parse_record_placement (lexer, &record, &column))
return false;
- if (lex_token (lexer) == T_STRING)
+ if (lex_is_string (lexer))
ok = parse_string_argument (lexer, trns, record, &column);
else
ok = parse_variable_argument (lexer, dict, trns, tmp_pool, &record, &column,
if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
return CMD_FAILURE;
- if (lex_token (lexer) != T_STRING)
+ if (!lex_force_string (lexer))
{
- msg (SE, _("String expected for variable label."));
free (v);
return CMD_FAILURE;
}
if (lex_is_number (lexer))
width = 0;
- else if (lex_token (lexer) == T_STRING)
+ else if (lex_is_string (lexer))
width = ds_length (lex_tokstr (lexer));
else
{
bool
lex_force_string (struct lexer *lexer)
{
- if (lexer->token == T_STRING)
+ if (lex_is_string (lexer))
return true;
else
{
else if (s->value == VAL_STRING)
{
dump (1, "if (lex_token (lexer) != T_ID "
- "&& lex_token (lexer) != T_STRING)");
+ "&& !lex_is_string (lexer))");
dump (1, "{");
dump (0, "msg (SE, _(\"%s specifier of %s subcommand "
"requires a string argument.\"));",
lex_get (lexer);
return true;
}
- else if (lex_token (lexer) == T_STRING && format != NULL)
+ else if (lex_is_string (lexer) && format != NULL)
{
union value v;
assert (! (fmt_get_category (*format) & ( FMT_CAT_STRING )));
- if (lex_token (lexer) == T_STRING)
+ if (lex_is_string (lexer))
{
struct string label;
ds_init_string (&label, lex_tokstr (lexer));
int type;
lex_match (lexer, ',');
- if (lex_token (lexer) == T_STRING)
+ if (lex_is_string (lexer))
{
arg[i].c = ds_xstrdup (lex_tokstr (lexer));
type = VAL_STRING;
/* PSPP - a program for statistical analysis.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
char format_string[FMT_STRING_LEN_MAX + 1];
g = fmt_guesser_create ();
- while (lex_token (lexer) == T_STRING)
+ while (lex_is_string (lexer))
{
fprintf (stderr, "\"%s\" ", ds_cstr (lex_tokstr (lexer)));
fmt_guesser_add (g, ds_ss (lex_tokstr (lexer)));
/* PSPP - a program for statistical analysis.
- Copyright (C) 2005, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
{
struct tab_table *tab;
- if (lex_token (lexer) != T_STRING)
+ if (!lex_force_string (lexer))
return CMD_FAILURE;
tab = tab_create(1, 1);
return CMD_FAILURE;
ds_init_empty (&command);
- while (lex_token (lexer) == T_STRING)
+ while (lex_is_string (lexer))
{
if (!ds_is_empty (&command))
ds_put_char (&command, '\n');
lex_match (lexer, '=');
/* File name can be identifier or string. */
- if (lex_token (lexer) != T_ID && lex_token (lexer) != T_STRING)
+ if (lex_token (lexer) != T_ID && !lex_is_string (lexer))
{
lex_error (lexer, _("expecting file name"));
return CMD_FAILURE;
journal_enable ();
else if (lex_match_id (lexer, "OFF") || lex_match_id (lexer, "NO"))
journal_disable ();
- else if (lex_token (lexer) == T_STRING || lex_token (lexer) == T_ID)
+ else if (lex_is_string (lexer) || lex_token (lexer) == T_ID)
{
journal_set_file_name (ds_cstr (lex_tokstr (lexer)));
lex_get (lexer);
}
else if (lex_match_id (lexer, "SYSMIS"))
set_map_out_num (out, SYSMIS);
- else if (lex_token (lexer) == T_STRING)
+ else if (lex_is_string (lexer))
{
set_map_out_str (out, pool, lex_tokstr (lexer));
lex_get (lexer);