It seems useful to have a type that indicates that a value is a token.
Furthermore, being able to enumerate all of the possible tokens in a
straightforward way seems worthwhile. It also makes it possible for
GCC to check "switch" statements on token types and to build arrays
indexed by token.
/* Returns true if TOKEN is representable as a keyword. */
bool
-lex_is_keyword (int token)
+lex_is_keyword (enum token_type token)
{
const struct keyword *kw;
for (kw = keywords; kw < &keywords[keyword_cnt]; kw++)
/* Returns the name for the given keyword token type. */
const char *
-lex_id_name (int token)
+lex_id_name (enum token_type token)
{
const struct keyword *kw;
#include "libpspp/str.h"
/* Token types. */
-enum
+enum token_type
{
- T_ID = 256, /* Identifier. */
+ T_ID = 1, /* Identifier. */
T_POS_NUM, /* Positive number. */
T_NEG_NUM, /* Negative number. */
T_STRING, /* Quoted string. */
T_STOP, /* End of input. */
+ T_ENDCMD, /* End of command (e.g. '.'). */
+
+ T_PLUS, /* + */
+ T_DASH, /* - */
+ T_ASTERISK, /* * */
+ T_SLASH, /* / */
+ T_EQUALS, /* = */
+ T_LPAREN, /* ( */
+ T_RPAREN, /* ) */
+ T_LBRACK, /* [ */
+ T_RBRACK, /* ] */
+ T_COMMA, /* , */
+
T_AND, /* AND */
T_OR, /* OR */
T_NOT, /* NOT */
};
/* Tokens. */
-bool lex_is_keyword (int token);
+bool lex_is_keyword (enum token_type);
/* Recognizing identifiers. */
bool lex_is_id1 (char);
int lex_id_to_token (struct substring);
/* Identifier names. */
-const char *lex_id_name (int);
+const char *lex_id_name (enum token_type);
#endif /* !data/identifier.h */
result = CMD_EOF;
goto finish;
}
- else if (lex_token (lexer) == '.')
+ else if (lex_token (lexer) == T_ENDCMD)
{
/* Null commands can result from extra empty lines. */
result = CMD_SUCCESS;
struct string s;
if (lex_token (lexer) == T_EXP
- || lex_token (lexer) == '*'
- || lex_token (lexer) == '[')
+ || lex_token (lexer) == T_ASTERISK
+ || lex_token (lexer) == T_LBRACK)
{
static const struct command c = { S_ANY, 0, "COMMENT", cmd_comment };
return &c;
ds_init_empty (&s);
for (;;)
{
- if (lex_token (lexer) == '-')
+ if (lex_token (lexer) == T_DASH)
ds_put_byte (&s, '-');
else if (lex_token (lexer) == T_ID)
{
if (!lex_force_match_id (lexer, "FILE"))
return CMD_FAILURE;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
return CMD_FAILURE;
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
bool ok = true;
loop = create_loop_trns (ds);
- while (lex_token (lexer) != '.' && ok)
+ while (lex_token (lexer) != T_ENDCMD && ok)
{
if (lex_match_id (lexer, "IF"))
ok = parse_if_clause (lexer, loop, &loop->loop_condition);
}
lex_get (lexer);
- if (!lex_force_match (lexer, '='))
+ if (!lex_force_match (lexer, T_EQUALS))
return false;
loop->first_expr = expr_parse_pool (lexer, loop->pool,
/* Skip equals sign. */
lex_get (lexer);
- if (!lex_force_match (lexer, '='))
+ if (!lex_force_match (lexer, T_EQUALS))
return false;
/* Get the details of the variable's possible values. */
}
if (count == 0)
return false;
- if (lex_token (lexer) != '/' && lex_token (lexer) != '.')
+ if (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
{
lex_error (lexer, NULL);
return false;
return false;
}
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
}
- while (lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_ENDCMD);
return true;
}
add_replacement (ss_cstr (pool_asprintf (pool, "%g", i)),
macro, pool, &used, &allocated);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD);
return used;
}
add_replacement (ss_cstr (string), macro, pool, &used, &allocated);
lex_get (lexer);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD);
return used;
}
dict_set_case_limit (proc.dict, dict_get_case_limit (dataset_dict (ds)));
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
for (;;)
{
struct comb_file *file;
}
else
break;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (proc.n_files >= allocated_files)
proc.files = x2nrealloc (proc.files, &allocated_files,
file->in_name[0] = '\0';
file->in_var = NULL;
- if (lex_match (lexer, '*'))
+ if (lex_match (lexer, T_ASTERISK))
{
if (!proc_has_active_file (ds))
{
goto error;
}
- while (lex_match (lexer, '/'))
+ while (lex_match (lexer, T_SLASH))
if (lex_match_id (lexer, "RENAME"))
{
if (!parse_dict_rename (lexer, file->dict))
}
else if (lex_match_id (lexer, "IN"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_token (lexer) != T_ID)
{
lex_error (lexer, NULL);
merge_dictionary (proc.dict, file);
}
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
if (lex_match (lexer, T_BY))
{
}
saw_by = true;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_sort_criteria (lexer, proc.dict, &proc.by_vars,
&by_vars, NULL))
goto error;
goto error;
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_id (lexer))
goto error;
strcpy (first_name, lex_tokid (lexer));
goto error;
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_id (lexer))
goto error;
strcpy (last_name, lex_tokid (lexer));
goto error;
}
- if (!lex_match (lexer, '/') && lex_token (lexer) != '.')
+ if (!lex_match (lexer, T_SLASH) && lex_token (lexer) != T_ENDCMD)
{
lex_end_of_command (lexer);
goto error;
table = -1; /* Print table if nonzero, -1=undecided. */
has_type = false;
- while (lex_token (lexer) != '/')
+ while (lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "FILE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
fh_unref (fh);
fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE);
if (fh == NULL)
}
else if (lex_match_id (lexer, "ENCODING"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
}
else if (lex_match_id (lexer, "RECORDS"))
{
- lex_match (lexer, '=');
- lex_match (lexer, '(');
+ lex_match (lexer, T_EQUALS);
+ lex_match (lexer, T_LPAREN);
if (!lex_force_int (lexer))
goto error;
data_parser_set_records (parser, lex_integer (lexer));
lex_get (lexer);
- lex_match (lexer, ')');
+ lex_match (lexer, T_RPAREN);
}
else if (lex_match_id (lexer, "SKIP"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_int (lexer))
goto error;
data_parser_set_skip (parser, lex_integer (lexer));
goto error;
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_id (lexer))
goto error;
end = dict_lookup_var (dict, lex_tokid (lexer));
if (data_parser_get_type (parser) == DP_DELIMITED)
{
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
struct string delims = DS_EMPTY_INITIALIZER;
- while (!lex_match (lexer, ')'))
+ while (!lex_match (lexer, T_RPAREN))
{
int delim;
}
ds_put_byte (&delims, delim);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
data_parser_set_empty_line_has_field (parser, true);
int record = 0;
int column = 1;
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
char **names;
size_t name_cnt, name_idx;
struct pool *tmp_pool, struct data_parser *parser)
{
lex_get (lexer);
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
struct fmt_spec input, output;
char **name;
&name, &name_cnt, PV_NONE))
return false;
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
if (!parse_format_specifier (lexer, &input)
|| !fmt_check_input (&input)
- || !lex_force_match (lexer, ')'))
+ || !lex_force_match (lexer, T_RPAREN))
return NULL;
/* As a special case, N format is treated as F format
}
else
{
- lex_match (lexer, '*');
+ lex_match (lexer, T_ASTERISK);
input = fmt_for_input (FMT_F, 8, 0);
output = *settings_get_format ();
}
{
r->flags |= DFM_SAW_BEGIN_DATA;
- while (lex_token (r->lexer) == '.')
+ while (lex_token (r->lexer) == T_ENDCMD)
lex_get (r->lexer);
if (!lex_force_match_id (r->lexer, "BEGIN") || !lex_force_match_id (r->lexer, "DATA"))
return false;
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 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
}
lex_get (lexer);
- if (!lex_force_match (lexer, '/'))
+ if (!lex_force_match (lexer, T_SLASH))
return CMD_CASCADING_FAILURE;
if (!parse_file_handle (lexer, ds, &cmd, NULL))
int
cmd_get_data (struct lexer *lexer, struct dataset *ds)
{
- lex_force_match (lexer, '/');
+ lex_force_match (lexer, T_SLASH);
if (!lex_force_match_id (lexer, "TYPE"))
return CMD_FAILURE;
- lex_force_match (lexer, '=');
+ lex_force_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "GNM"))
return parse_get_gnm (lexer, ds);
psql.bsize = -1;
ds_init_empty (&psql.sql);
- lex_force_match (lexer, '/');
+ lex_force_match (lexer, T_SLASH);
if (!lex_force_match_id (lexer, "CONNECT"))
goto error;
- lex_force_match (lexer, '=');
+ lex_force_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
lex_get (lexer);
- while (lex_match (lexer, '/') )
+ while (lex_match (lexer, T_SLASH) )
{
if ( lex_match_id (lexer, "ASSUMEDSTRWIDTH"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
psql.str_width = lex_integer (lexer);
lex_get (lexer);
}
else if ( lex_match_id (lexer, "BSIZE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
psql.bsize = lex_integer (lexer);
lex_get (lexer);
}
}
else if (lex_match_id (lexer, "SQL"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ( ! lex_force_string (lexer) )
goto error;
{
struct gnumeric_read_info gri = {NULL, NULL, NULL, 1, true, -1};
- lex_force_match (lexer, '/');
+ lex_force_match (lexer, T_SLASH);
if (!lex_force_match_id (lexer, "FILE"))
goto error;
- lex_force_match (lexer, '=');
+ lex_force_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
lex_get (lexer);
- while (lex_match (lexer, '/') )
+ while (lex_match (lexer, T_SLASH) )
{
if ( lex_match_id (lexer, "ASSUMEDSTRWIDTH"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
gri.asw = lex_integer (lexer);
}
else if (lex_match_id (lexer, "SHEET"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "NAME"))
{
if ( ! lex_force_string (lexer) )
}
else if (lex_match_id (lexer, "CELLRANGE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "FULL"))
{
}
else if (lex_match_id (lexer, "READNAMES"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ( lex_match_id (lexer, "ON"))
{
enum data_parser_type type;
bool has_type;
- lex_force_match (lexer, '/');
+ lex_force_match (lexer, T_SLASH);
if (!lex_force_match_id (lexer, "FILE"))
goto error;
- lex_force_match (lexer, '=');
+ lex_force_match (lexer, T_EQUALS);
fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE);
if (fh == NULL)
goto error;
for (;;)
{
- if (!lex_force_match (lexer, '/'))
+ if (!lex_force_match (lexer, T_SLASH))
goto error;
if (lex_match_id (lexer, "ARRANGEMENT"))
{
bool ok;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "FIXED"))
ok = set_type (parser, "ARRANGEMENT=FIXED", DP_FIXED, &has_type);
else if (lex_match_id (lexer, "DELIMITED"))
}
else if (lex_match_id (lexer, "FIRSTCASE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_int (lexer))
goto error;
if (lex_integer (lexer) < 1)
{
if (!set_type (parser, "DELCASE", DP_DELIMITED, &has_type))
goto error;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "LINE"))
data_parser_set_span (parser, false);
else if (lex_match_id (lexer, "VARIABLES"))
{
if (!set_type (parser, "FIXCASE", DP_FIXED, &has_type))
goto error;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_int (lexer))
goto error;
if (lex_integer (lexer) < 1)
}
else if (lex_match_id (lexer, "IMPORTCASES"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match (lexer, T_ALL))
{
data_parser_set_case_limit (parser, -1);
if (!set_type (parser, "DELIMITERS", DP_DELIMITED, &has_type))
goto error;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
{
if (!set_type (parser, "QUALIFIERS", DP_DELIMITED, &has_type))
goto error;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
goto error;
}
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
record = 1;
int fc, lc;
struct variable *v;
- while (type == DP_FIXED && lex_match (lexer, '/'))
+ while (type == DP_FIXED && lex_match (lexer, T_SLASH))
{
if (!lex_force_int (lexer))
goto error;
data_parser_add_fixed_field (parser, &input, var_get_case_index (v),
name, record, fc);
}
- while (lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_ENDCMD);
reader = dfm_open_reader (fh, lexer);
if (reader == NULL)
for (;;)
{
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "FILE") || lex_is_string (lexer))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
fh_unref (fh);
fh = fh_parse (lexer, FH_REF_FILE | FH_REF_SCRATCH);
}
else if (type == IMPORT_CMD && lex_match_id (lexer, "TYPE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "COMM"))
type = PFM_COMM;
case_map_prepare_dict (dict);
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (!parse_dict_trim (lexer, dict))
goto error;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
bool saw_END_CASE = false;
proc_discard_active_file (ds);
- if (lex_token (lexer) != '.')
+ if (lex_token (lexer) != T_ENDCMD)
return lex_end_of_command (lexer);
inp = xmalloc (sizeof *inp);
cmd_end_case (struct lexer *lexer, struct dataset *ds UNUSED)
{
assert (in_input_program ());
- if (lex_token (lexer) == '.')
+ if (lex_token (lexer) == T_ENDCMD)
return CMD_END_CASE;
return lex_end_of_command (lexer);
}
fh = fh_get_default_handle ();
e = NULL;
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
if (lex_match_id (lexer, "COLUMN"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (e)
{
}
else if (lex_match_id (lexer, "FILE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
fh_unref (fh);
fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE);
if (fh == NULL)
/* PSPP - a program for statistical analysis.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 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
assert (var_cnt > 0);
if (lex_is_number (lexer))
return fixed_parse_columns (lexer, pool, var_cnt, for_input, formats, format_cnt);
- else if (lex_match (lexer, '('))
+ else if (lex_match (lexer, T_LPAREN))
{
size_t assignment_cnt;
size_t i;
}
/* Format specifier. */
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
/* Get format type. */
if (lex_token (lexer) == T_ID)
{
if (!parse_format_specifier_name (lexer, &format.type))
return false;
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
else
format.type = FMT_F;
else
format.d = 0;
- if (!lex_force_match (lexer, ')'))
+ if (!lex_force_match (lexer, T_RPAREN))
return false;
}
else
size_t formats_used = 0;
*formats = NULL;
- while (!lex_match (lexer, ')'))
+ while (!lex_match (lexer, T_RPAREN))
{
struct fmt_spec f;
struct fmt_spec *new_formats;
count = 1;
/* Parse format specifier. */
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
/* Call ourselves recursively to handle parentheses. */
if (!fixed_parse_fortran (lexer, pool, for_input,
{
new_formats = &f;
new_format_cnt = 1;
- if (lex_match (lexer, '/'))
+ if (lex_match (lexer, T_SLASH))
f.type = PRS_TYPE_NEW_REC;
else
{
formats_used += new_format_cnt;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
*format_cnt = formats_used;
/* Last column. */
lex_negative_to_dash (lexer);
- if (lex_match (lexer, '-'))
+ if (lex_match (lexer, T_DASH))
{
if (!parse_column (lexer, base, last_column))
return false;
bool
parse_record_placement (struct lexer *lexer, int *record, int *column)
{
- while (lex_match (lexer, '/'))
+ while (lex_match (lexer, T_SLASH))
{
if (lex_is_integer (lexer))
{
/* PSPP - a program for statistical analysis.
- Copyright (C) 2006, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2006, 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
if (lex_match_id (lexer, "OUTFILE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
handle = fh_parse (lexer, FH_REF_FILE);
if (handle == NULL)
else
handle = NULL;
- if (lex_token (lexer) != '.')
+ if (lex_token (lexer) != T_ENDCMD)
{
expr = expr_parse (lexer, ds, EXPR_NUMBER);
- if (lex_token (lexer) != '.')
+ if (lex_token (lexer) != T_ENDCMD)
{
expr_free (expr);
lex_error (lexer, _("expecting end of command"));
tmp_pool = pool_create_subpool (trns->pool);
/* Parse the command options. */
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
{
if (lex_match_id (lexer, "OUTFILE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
fh = fh_parse (lexer, FH_REF_FILE);
if (fh == NULL)
}
else if (lex_match_id (lexer, "RECORDS"))
{
- lex_match (lexer, '=');
- lex_match (lexer, '(');
+ lex_match (lexer, T_EQUALS);
+ lex_match (lexer, T_LPAREN);
if (!lex_force_int (lexer))
goto error;
trns->record_cnt = lex_integer (lexer);
lex_get (lexer);
- lex_match (lexer, ')');
+ lex_match (lexer, T_RPAREN);
}
else if (lex_match_id (lexer, "TABLE"))
print_table = true;
int record = 0;
int column = 1;
- if (lex_token (lexer) == '.')
+ if (lex_token (lexer) == T_ENDCMD)
{
trns->record_cnt = 1;
return true;
}
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
bool ok;
if (!ok)
return 0;
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
if (trns->record_cnt != 0 && trns->record_cnt != record)
&vars, &var_cnt, PV_DUPLICATE))
return false;
- if (lex_is_number (lexer) || lex_token (lexer) == '(')
+ if (lex_is_number (lexer) || lex_token (lexer) == T_LPAREN)
{
if (!parse_var_placements (lexer, tmp_pool, var_cnt, false,
&formats, &format_cnt))
{
size_t i;
- lex_match (lexer, '*');
+ lex_match (lexer, T_ASTERISK);
formats = pool_nmalloc (tmp_pool, var_cnt, sizeof *formats);
format_cnt = var_cnt;
case_map_prepare_dict (dict);
dict_delete_scratch_vars (dict);
- while (lex_match (lexer, '/'))
+ while (lex_match (lexer, T_SLASH))
{
if (lex_match_id (lexer, "OUTFILE"))
{
goto error;
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
handle = fh_parse (lexer, FH_REF_FILE);
if (handle == NULL)
goto error;
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "CSV"))
type = CSV_FILE;
else if (lex_match_id (lexer, "TAB"))
include_var_names = true;
else if (lex_match_id (lexer, "MISSING"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "IGNORE"))
recode_user_missing = false;
else if (lex_match_id (lexer, "RECODE"))
}
else if (lex_match_id (lexer, "CELLS"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "VALUES"))
use_value_labels = false;
else if (lex_match_id (lexer, "LABELS"))
}
else if (lex_match_id (lexer, "TEXTOPTIONS"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
for (;;)
{
if (lex_match_id (lexer, "DELIMITER"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
if (ds_length (lex_tokstr (lexer)) != 1)
}
else if (lex_match_id (lexer, "QUALIFIER"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
if (ds_length (lex_tokstr (lexer)) != 1)
}
else if (lex_match_id (lexer, "DECIMAL"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "DOT"))
decimal = '.';
else if (lex_match_id (lexer, "COMMA"))
}
else if (lex_match_id (lexer, "FORMAT"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "PLAIN"))
use_print_formats = false;
else if (lex_match_id (lexer, "VARIABLE"))
}
else if (lex_match_id (lexer, "UNSELECTED"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "RETAIN"))
retain_unselected = true;
else if (lex_match_id (lexer, "DELETE"))
case_map_prepare_dict (dict);
dict_delete_scratch_vars (dict);
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
for (;;)
{
if (lex_match_id (lexer, "OUTFILE"))
goto error;
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
handle = fh_parse (lexer, FH_REF_FILE | FH_REF_SCRATCH);
if (handle == NULL)
{
bool cw;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "READONLY"))
cw = false;
else if (lex_match_id (lexer, "WRITEABLE"))
}
else if (command_type == PROC_CMD && lex_match_id (lexer, "UNSELECTED"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "RETAIN"))
*retain_unselected = true;
else if (lex_match_id (lexer, "DELETE"))
else if (writer_type == SYSFILE_WRITER
&& lex_match_id (lexer, "VERSION"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_int (lexer))
goto error;
sysfile_opts.version = lex_integer (lexer);
}
else if (writer_type == PORFILE_WRITER && lex_match_id (lexer, "TYPE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "COMMUNICATIONS"))
porfile_opts.type = PFM_COMM;
else if (lex_match_id (lexer, "TAPE"))
}
else if (writer_type == PORFILE_WRITER && lex_match_id (lexer, "DIGITS"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_int (lexer))
goto error;
porfile_opts.digits = lex_integer (lexer);
else if (!parse_dict_trim (lexer, dict))
goto error;
- if (!lex_match (lexer, '/'))
+ if (!lex_match (lexer, T_SLASH))
break;
}
if (lex_end_of_command (lexer) != CMD_SUCCESS)
int group;
- lex_match (lexer, '=');
- if (lex_token (lexer) != '(')
+ lex_match (lexer, T_EQUALS);
+ if (lex_token (lexer) != T_LPAREN)
{
struct variable *v;
v = parse_variable (lexer, dict);
if (v == NULL)
return 0;
- if (!lex_force_match (lexer, '=')
+ if (!lex_force_match (lexer, T_EQUALS)
|| !lex_force_id (lexer))
return 0;
if (dict_lookup_var (dict, lex_tokid (lexer)) != NULL)
v = NULL;
new_names = 0;
group = 1;
- while (lex_match (lexer, '('))
+ while (lex_match (lexer, T_LPAREN))
{
size_t old_nv = nv;
if (!parse_variables (lexer, dict, &v, &nv, PV_NO_DUPLICATE | PV_APPEND))
goto done;
- if (!lex_match (lexer, '='))
+ if (!lex_match (lexer, T_EQUALS))
{
msg (SE, _("`=' expected after variable list."));
goto done;
nv - old_nv, nn - old_nv, group);
goto done;
}
- if (!lex_force_match (lexer, ')'))
+ if (!lex_force_match (lexer, T_RPAREN))
goto done;
group++;
}
struct variable **v;
size_t nv;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_variables (lexer, dict, &v, &nv, PV_NONE))
return false;
dict_delete_vars (dict, v, nv);
size_t nv;
size_t i;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_variables (lexer, dict, &v, &nv, PV_NONE))
return false;
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
int i;
lex_match_id (lexer, "FROM");
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
handle = fh_parse (lexer, FH_REF_FILE | FH_REF_SCRATCH);
if (!handle)
/* 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
bool ok;
if (!lex_force_match_id (lexer, "VARIABLES")
- || !lex_force_match (lexer, '=')
+ || !lex_force_match (lexer, T_EQUALS)
|| !parse_variables (lexer, dataset_dict (ds), &vars, &n_vars,
PV_NONE))
return CMD_FAILURE;
if (!ok)
return CMD_FAILURE;
}
- while (lex_match (lexer, '/'));
+ while (lex_match (lexer, T_SLASH));
return lex_end_of_command (lexer);
}
{
if (lex_token (lexer) == T_ID
&& lex_id_match (ss_cstr (lex_tokid (lexer)), ss_cstr (keyword))
- && lex_look_ahead (lexer) == '=')
+ && lex_look_ahead (lexer) == T_EQUALS)
{
lex_get (lexer); /* Skip keyword. */
lex_get (lexer); /* Skip '='. */
strcpy (name, lex_tokid (lexer));
lex_get (lexer);
- if (lex_match (lexer, '['))
+ if (lex_match (lexer, T_LBRACK))
{
if (!lex_force_int (lexer))
return false;
}
*index = lex_integer (lexer);
lex_get (lexer);
- if (!lex_force_match (lexer, ']'))
+ if (!lex_force_match (lexer, T_RBRACK))
return false;
}
else
char *value;
if (!parse_attribute_name (lexer, name, &index)
- || !lex_force_match (lexer, '(')
+ || !lex_force_match (lexer, T_LPAREN)
|| !lex_force_string (lexer))
return false;
value = ds_cstr (lex_tokstr (lexer));
}
lex_get (lexer);
- return lex_force_match (lexer, ')');
+ return lex_force_match (lexer, T_RPAREN);
}
static bool
: delete_attribute (lexer, sets, n)))
return CMD_FAILURE;
}
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD);
return CMD_SUCCESS;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 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
for (;;)
{
- if (lex_token (lexer) == '.')
+ if (lex_token (lexer) == T_ENDCMD)
break;
if (!parse_variables (lexer, dataset_dict (ds), &v, &cv, PV_NUMERIC))
return CMD_FAILURE;
type = var_get_type (v[0]);
- if (!lex_match (lexer, '('))
+ if (!lex_match (lexer, T_LPAREN))
{
msg (SE, _("`(' expected after variable list."));
goto fail;
|| !fmt_check_type_compat (&f, VAL_NUMERIC))
goto fail;
- if (!lex_match (lexer, ')'))
+ if (!lex_match (lexer, T_RPAREN))
{
msg (SE, _("`)' expected after output format."));
goto fail;
int retval = CMD_FAILURE;
bool deferred_errors = false;
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
size_t i;
if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
goto done;
- if (!lex_force_match (lexer, '('))
+ if (!lex_force_match (lexer, T_LPAREN))
goto done;
for (i = 0; i < nv; i++)
var_clear_missing_values (v[i]);
- if (!lex_match (lexer, ')'))
+ if (!lex_match (lexer, T_RPAREN))
{
struct missing_values mv;
if (var_is_numeric (v[0]))
{
mv_init (&mv, 0);
- while (!lex_match (lexer, ')'))
+ while (!lex_match (lexer, T_RPAREN))
{
enum fmt_type type = var_get_print_format (v[0])->type;
double x, y;
if (!ok)
deferred_errors = true;
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
}
else
{
mv_init (&mv, MV_MAX_STRING);
- while (!lex_match (lexer, ')'))
+ while (!lex_match (lexer, T_RPAREN))
{
uint8_t value[MV_MAX_STRING];
size_t length;
deferred_errors = true;
lex_get (lexer);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
}
mv_destroy (&mv);
}
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
free (v);
v = NULL;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
vm.drop_cnt = 0;
/* Parse each subcommand. */
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
for (;;)
{
if (lex_match_id (lexer, "REORDER"))
}
already_encountered |= 1;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
do
{
struct ordering ordering;
else if (lex_match_id (lexer, "ALPHA"))
ordering.positional = 0;
- if (lex_match (lexer, T_ALL) || lex_token (lexer) == '/' || lex_token (lexer) == '.')
+ if (lex_match (lexer, T_ALL) || lex_token (lexer) == T_SLASH || lex_token (lexer) == T_ENDCMD)
{
if (prev_nv != 0)
{
}
else
{
- if (!lex_match (lexer, '('))
+ if (!lex_match (lexer, T_LPAREN))
{
msg (SE, _("`(' expected on %s subcommand."), "REORDER");
free (v);
free (v);
goto done;
}
- if (!lex_match (lexer, ')'))
+ if (!lex_match (lexer, T_RPAREN))
{
msg (SE, _("`)' expected following variable names on "
"REORDER subcommand."));
sort (&v[prev_nv], nv - prev_nv, sizeof *v,
compare_variables_given_ordering, &ordering);
}
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_SLASH
+ && lex_token (lexer) != T_ENDCMD);
vm.reorder_vars = v;
vm.reorder_cnt = nv;
}
already_encountered |= 2;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
do
{
size_t prev_nv_1 = vm.rename_cnt;
size_t prev_nv_2 = vm.rename_cnt;
- if (!lex_match (lexer, '('))
+ if (!lex_match (lexer, T_LPAREN))
{
msg (SE, _("`(' expected on %s subcommand."), "RENAME");
goto done;
&vm.rename_vars, &vm.rename_cnt,
PV_APPEND | PV_NO_DUPLICATE))
goto done;
- if (!lex_match (lexer, '='))
+ if (!lex_match (lexer, T_EQUALS))
{
msg (SE, _("`=' expected between lists of new and old variable "
"names on RENAME subcommand."));
vm.new_names = NULL;
goto done;
}
- if (!lex_match (lexer, ')'))
+ if (!lex_match (lexer, T_RPAREN))
{
msg (SE, _("`)' expected after variable lists on RENAME "
"subcommand."));
goto done;
}
}
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/');
+ while (lex_token (lexer) != T_ENDCMD
+ && lex_token (lexer) != T_SLASH);
}
else if (lex_match_id (lexer, "KEEP"))
{
}
already_encountered |= 4;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_variables (lexer, dataset_dict (ds), &keep_vars, &keep_cnt, PV_NONE))
goto done;
}
already_encountered |= 4;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_variables (lexer, dataset_dict (ds), &drop_vars, &drop_cnt, PV_NONE))
goto done;
vm.drop_vars = drop_vars;
goto done;
}
- if (lex_token (lexer) == '.')
+ if (lex_token (lexer) == T_ENDCMD)
break;
- if (lex_token (lexer) != '/')
+ if (lex_token (lexer) != T_SLASH)
{
msg (SE, _("`/' or `.' expected."));
goto done;
{
struct dictionary *dict = dataset_dict (ds);
- while (lex_match (lexer, '/'))
+ while (lex_match (lexer, T_SLASH))
{
bool ok;
labelsource_varlabel = false;
has_value = false;
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
{
if (lex_match_id (lexer, "NAME"))
{
- if (!lex_force_match (lexer, '=') || !lex_force_id (lexer))
+ if (!lex_force_match (lexer, T_EQUALS) || !lex_force_id (lexer))
goto error;
if (lex_tokid (lexer)[0] != '$')
{
}
else if (lex_match_id (lexer, "VARIABLES"))
{
- if (!lex_force_match (lexer, '='))
+ if (!lex_force_match (lexer, T_EQUALS))
goto error;
free (mrset->vars);
}
else if (lex_match_id (lexer, "LABEL"))
{
- if (!lex_force_match (lexer, '=') || !lex_force_string (lexer))
+ if (!lex_force_match (lexer, T_EQUALS) || !lex_force_string (lexer))
goto error;
free (mrset->label);
}
else if (type == MRSET_MD && lex_match_id (lexer, "LABELSOURCE"))
{
- if (!lex_force_match (lexer, '=')
+ if (!lex_force_match (lexer, T_EQUALS)
|| !lex_force_match_id (lexer, "VARLABEL"))
goto error;
}
else if (type == MRSET_MD && lex_match_id (lexer, "VALUE"))
{
- if (!lex_force_match (lexer, '='))
+ if (!lex_force_match (lexer, T_EQUALS))
goto error;
has_value = true;
}
else if (type == MRSET_MD && lex_match_id (lexer, "CATEGORYLABELS"))
{
- if (!lex_force_match (lexer, '='))
+ if (!lex_force_match (lexer, T_EQUALS))
goto error;
if (lex_match_id (lexer, "VARLABELS"))
parse_mrset_names (struct lexer *lexer, struct dictionary *dict,
struct stringi_set *mrset_names)
{
- if (!lex_force_match_id (lexer, "NAME") || !lex_force_match (lexer, '='))
+ if (!lex_force_match_id (lexer, "NAME")
+ || !lex_force_match (lexer, T_EQUALS))
return false;
stringi_set_init (mrset_names);
- if (lex_match (lexer, '['))
+ if (lex_match (lexer, T_LBRACK))
{
- while (!lex_match (lexer, ']'))
+ while (!lex_match (lexer, T_RBRACK))
{
if (!lex_force_id (lexer))
return false;
return CMD_FAILURE;
/* Get the optional format specification. */
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
if (!parse_format_specifier (lexer, &f))
goto fail;
goto fail;
}
- if (!lex_match (lexer, ')'))
+ if (!lex_match (lexer, T_RPAREN))
{
msg (SE, _("`)' expected after output format."));
goto fail;
free (v[i]);
free (v);
}
- while (lex_match (lexer, '/'));
+ while (lex_match (lexer, T_SLASH));
return lex_end_of_command (lexer);
if (!parse_DATA_LIST_vars (lexer, &v, &nv, PV_NO_DUPLICATE))
return CMD_FAILURE;
- if (!lex_force_match (lexer, '(')
+ if (!lex_force_match (lexer, T_LPAREN)
|| !parse_format_specifier (lexer, &f)
- || !lex_force_match (lexer, ')'))
+ || !lex_force_match (lexer, T_RPAREN))
goto fail;
if (!fmt_is_string (f.type))
{
free (v[i]);
free (v);
}
- while (lex_match (lexer, '/'));
+ while (lex_match (lexer, T_SLASH));
return lex_end_of_command (lexer);
size_t prev_nv_1 = rename_cnt;
size_t prev_nv_2 = rename_cnt;
- if (!lex_match (lexer, '('))
+ if (!lex_match (lexer, T_LPAREN))
{
msg (SE, _("`(' expected."));
goto lossage;
if (!parse_variables (lexer, dataset_dict (ds), &rename_vars, &rename_cnt,
PV_APPEND | PV_NO_DUPLICATE))
goto lossage;
- if (!lex_match (lexer, '='))
+ if (!lex_match (lexer, T_EQUALS))
{
msg (SE, _("`=' expected between lists of new and old variable names."));
goto lossage;
rename_new_names = NULL;
goto lossage;
}
- if (!lex_match (lexer, ')'))
+ if (!lex_match (lexer, T_RPAREN))
{
msg (SE, _("`)' expected after variable names."));
goto lossage;
}
}
- while (lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_ENDCMD);
if (!dict_rename_vars (dataset_dict (ds),
rename_vars, rename_new_names, rename_cnt,
int r, i;
lex_match_id (lexer, "FILE");
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
h = fh_parse (lexer, FH_REF_FILE);
if (!h)
break;
}
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
lex_match_id (lexer, "VARIABLES");
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
- if (lex_token (lexer) != '.')
+ if (lex_token (lexer) != T_ENDCMD)
{
if (!parse_variables_const (lexer, dataset_dict (ds), &vl, &n,
PV_NONE))
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
size_t var_cnt; /* Number of variables. */
int parse_err=0; /* true if error parsing variables */
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
parse_err = !parse_variables (lexer, dict, &vars, &var_cnt,
PV_SAME_WIDTH);
}
if (erase)
erase_labels (vars, var_cnt);
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
if (!get_label (lexer, vars, var_cnt))
goto lossage;
- if (lex_token (lexer) != '/')
+ if (lex_token (lexer) != T_SLASH)
{
free (vars);
break;
value_destroy (&value, width);
return 0;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
/* Set label. */
if (lex_token (lexer) != T_ID && !lex_force_string (lexer))
value_destroy (&value, width);
lex_get (lexer);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD);
return 1;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
return CMD_FAILURE;
- if ( lex_force_match (lexer, '(') )
+ if ( lex_force_match (lexer, T_LPAREN) )
{
if ( lex_match_id (lexer, "LEFT"))
align = ALIGN_LEFT;
return CMD_FAILURE;
}
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
else
{
for( i = 0 ; i < nv ; ++i )
var_set_alignment (v[i], align);
- while (lex_token (lexer) == '/')
+ while (lex_token (lexer) == T_SLASH)
lex_get (lexer);
free (v);
}
- while (lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_ENDCMD);
return CMD_SUCCESS;
}
if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
return CMD_FAILURE;
- if (!lex_force_match (lexer, '(') || !lex_force_int (lexer))
+ if (!lex_force_match (lexer, T_LPAREN) || !lex_force_int (lexer))
{
free (v);
return CMD_FAILURE;
}
width = lex_integer (lexer);
lex_get (lexer);
- if (!lex_force_match (lexer, ')'))
+ if (!lex_force_match (lexer, T_RPAREN))
{
free (v);
return CMD_FAILURE;
for( i = 0 ; i < nv ; ++i )
var_set_display_width (v[i], width);
- while (lex_token (lexer) == '/')
+ while (lex_token (lexer) == T_SLASH)
lex_get (lexer);
free (v);
}
- while (lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_ENDCMD);
return CMD_SUCCESS;
}
if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
return CMD_FAILURE;
- if ( lex_force_match (lexer, '(') )
+ if ( lex_force_match (lexer, T_LPAREN) )
{
if ( lex_match_id (lexer, "SCALE"))
level = MEASURE_SCALE;
return CMD_FAILURE;
}
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
else
{
var_set_measure (v[i], level);
- while (lex_token (lexer) == '/')
+ while (lex_token (lexer) == T_SLASH)
lex_get (lexer);
free (v);
}
- while (lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_ENDCMD);
return CMD_SUCCESS;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
ds_destroy (&label);
lex_get (lexer);
- while (lex_token (lexer) == '/')
+ while (lex_token (lexer) == T_SLASH)
lex_get (lexer);
free (v);
}
- while (lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_ENDCMD);
return CMD_SUCCESS;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
vectors[vector_cnt++] = pool_strdup (pool, lex_tokid (lexer));
lex_get (lexer);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
/* Now that we have the names it's time to check for the short
or long forms. */
- if (lex_match (lexer, '='))
+ if (lex_match (lexer, T_EQUALS))
{
/* Long form. */
struct variable **v;
dict_create_vector (dict, vectors[0], v, nv);
}
- else if (lex_match (lexer, '('))
+ else if (lex_match (lexer, T_LPAREN))
{
/* Short form. */
struct fmt_spec format;
var_cnt = 0;
format = fmt_for_output (FMT_F, 8, 2);
seen_format = false;
- while (!lex_match (lexer, ')'))
+ while (!lex_match (lexer, T_RPAREN))
{
if (lex_is_integer (lexer) && var_cnt == 0)
{
lex_error (lexer, NULL);
goto fail;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
if (var_cnt == 0)
{
goto fail;
}
}
- while (lex_match (lexer, '/'));
+ while (lex_match (lexer, T_SLASH));
pool_destroy (pool);
return lex_end_of_command (lexer);
optimize = 0;
else if (lex_match_id (lexer, "POSTFIX"))
dump_postfix = 1;
- else if (lex_match (lexer, '('))
+ else if (lex_match (lexer, T_LPAREN))
{
char name[VAR_NAME_LEN + 1];
struct variable *v;
strcpy (name, lex_tokid (lexer));
lex_get (lexer);
- if (!lex_force_match (lexer, '='))
+ if (!lex_force_match (lexer, T_EQUALS))
goto done;
if (lex_is_number (lexer))
if (!parse_value (lexer, case_data_rw (c, v), var_get_width (v)))
NOT_REACHED ();
- if (!lex_force_match (lexer, ')'))
+ if (!lex_force_match (lexer, T_RPAREN))
goto done;
}
else
break;
}
- if (lex_token (lexer) != '/')
+ if (lex_token (lexer) != T_SLASH)
{
- lex_force_match (lexer, '/');
+ lex_force_match (lexer, T_SLASH);
goto done;
}
for (op = ops; op < ops + op_cnt; op++)
{
- if (op->token == '-')
+ if (op->token == T_DASH)
lex_negative_to_dash (lexer);
if (lex_match (lexer, op->token))
{
{
static const struct operator ops[] =
{
- { '=', OP_EQ, "numeric equality (`=')" },
+ { T_EQUALS, OP_EQ, "numeric equality (`=')" },
{ T_EQ, OP_EQ, "numeric equality (`EQ')" },
{ T_GE, OP_GE, "numeric greater-than-or-equal-to (`>=')" },
{ T_GT, OP_GT, "numeric greater than (`>')" },
{
static const struct operator ops[] =
{
- { '=', OP_EQ_STRING, "string equality (`=')" },
+ { T_EQUALS, OP_EQ_STRING, "string equality (`=')" },
{ T_EQ, OP_EQ_STRING, "string equality (`EQ')" },
{ T_GE, OP_GE_STRING, "string greater-than-or-equal-to (`>=')" },
{ T_GT, OP_GT_STRING, "string greater than (`>')" },
{
static const struct operator ops[] =
{
- { '+', OP_ADD, "addition (`+')" },
- { '-', OP_SUB, "subtraction (`-')" },
+ { T_PLUS, OP_ADD, "addition (`+')" },
+ { T_DASH, OP_SUB, "subtraction (`-')" },
};
return parse_binary_operators (lexer, e, parse_mul (lexer, e),
{
static const struct operator ops[] =
{
- { '*', OP_MUL, "multiplication (`*')" },
- { '/', OP_DIV, "division (`/')" },
+ { T_ASTERISK, OP_MUL, "multiplication (`*')" },
+ { T_SLASH, OP_DIV, "division (`/')" },
};
return parse_binary_operators (lexer, e, parse_neg (lexer, e),
static union any_node *
parse_neg (struct lexer *lexer, struct expression *e)
{
- static const struct operator op = { '-', OP_NEG, "negation (`-')" };
+ static const struct operator op = { T_DASH, OP_NEG, "negation (`-')" };
return parse_inverting_unary_operator (lexer, e, &op, parse_exp);
}
switch (lex_token (lexer))
{
case T_ID:
- if (lex_look_ahead (lexer) == '(')
+ if (lex_look_ahead (lexer) == T_LPAREN)
{
/* An identifier followed by a left parenthesis may be
a vector element reference. If not, it's a function
return node;
}
- case '(':
+ case T_LPAREN:
{
union any_node *node;
lex_get (lexer);
node = parse_or (lexer, e);
- if (node != NULL && !lex_force_match (lexer, ')'))
+ if (node != NULL && !lex_force_match (lexer, T_RPAREN))
return NULL;
return node;
}
/* Skip left parenthesis token.
The caller must have verified that the lookahead is a left
parenthesis. */
- assert (lex_token (lexer) == '(');
+ assert (lex_token (lexer) == T_LPAREN);
lex_get (lexer);
element = parse_or (lexer, e);
if (!type_coercion (e, OP_number, &element, "vector indexing")
- || !lex_match (lexer, ')'))
+ || !lex_match (lexer, T_RPAREN))
return NULL;
return expr_allocate_binary (e, (vector_get_type (vector) == VAL_NUMERIC
}
lex_get (lexer);
- if (!lex_force_match (lexer, '('))
+ if (!lex_force_match (lexer, T_LPAREN))
{
ds_destroy (&func_name);
return NULL;
args = NULL;
arg_cnt = arg_cap = 0;
- if (lex_token (lexer) != ')')
+ if (lex_token (lexer) != T_RPAREN)
for (;;)
{
if (lex_token (lexer) == T_ID
- && toupper (lex_look_ahead (lexer)) == 'T')
+ && toupper (lex_look_ahead (lexer)) == T_ID)
{
const struct variable **vars;
size_t var_cnt;
add_arg (&args, &arg_cnt, &arg_cap, arg);
}
- if (lex_match (lexer, ')'))
+ if (lex_match (lexer, T_RPAREN))
break;
- else if (!lex_match (lexer, ','))
+ else if (!lex_match (lexer, T_COMMA))
{
lex_error (lexer, _("expecting `,' or `)' invoking %s function"),
first->name);
if (lexer->dot)
{
lexer->dot = 0;
- lexer->token = '.';
+ lexer->token = T_ENDCMD;
return;
}
else if (!lex_get_line (lexer))
if (!c_isdigit ((unsigned char) *lexer->prog) && *lexer->prog != '.')
{
- lexer->token = '-';
+ lexer->token = T_DASH;
break;
}
lexer->token = T_NEG_NUM;
lexer->token = parse_string (lexer, CHARACTER_STRING);
break;
- case '(': case ')': case ',': case '=': case '+': case '/':
- case '[': case ']':
- lexer->token = *lexer->prog++;
- break;
+ case '+':
+ lexer->token = T_PLUS;
+ lexer->prog++;
+ break;
+
+ case '/':
+ lexer->token = T_SLASH;
+ lexer->prog++;
+ break;
+
+ case '=':
+ lexer->token = T_EQUALS;
+ lexer->prog++;
+ break;
+
+ case '(':
+ lexer->token = T_LPAREN;
+ lexer->prog++;
+ break;
+
+ case ')':
+ lexer->token = T_RPAREN;
+ lexer->prog++;
+ break;
+
+ case '[':
+ lexer->token = T_LBRACK;
+ lexer->prog++;
+ break;
+
+ case ']':
+ lexer->token = T_RBRACK;
+ lexer->prog++;
+ break;
+
+ case ',':
+ lexer->token = T_COMMA;
+ lexer->prog++;
+ break;
case '*':
if (*++lexer->prog == '*')
lexer->token = T_EXP;
}
else
- lexer->token = '*';
+ lexer->token = T_ASTERISK;
break;
case '<':
if (lexer->token == T_STOP)
ds_put_cstr (&s, _("Syntax error at end of file"));
- else if (lexer->token == '.')
+ else if (lexer->token == T_ENDCMD)
ds_put_cstr (&s, _("Syntax error at end of command"));
else
{
int
lex_end_of_command (struct lexer *lexer)
{
- if (lexer->token != '.')
+ if (lexer->token != T_ENDCMD)
{
lex_error (lexer, _("expecting end of command"));
return CMD_FAILURE;
/* If TOK is the current token, skips it and returns true
Otherwise, returns false. */
bool
-lex_match (struct lexer *lexer, int t)
+lex_match (struct lexer *lexer, enum token_type t)
{
if (lexer->token == t)
{
/* If the current token is T, skips the token. Otherwise, reports an
error and returns from the current function with return value false. */
bool
-lex_force_match (struct lexer *lexer, int t)
+lex_force_match (struct lexer *lexer, enum token_type t)
{
if (lexer->token == t)
{
/* Weird token functions. */
-/* Returns the first character of the next token, except that if the
- next token is not an identifier, the character returned will not be
- a character that can begin an identifier. Specifically, the
- hexstring lead-in X' causes lookahead() to return '. Note that an
- alphanumeric return value doesn't guarantee an ID token, it could
- also be a reserved-word token. */
-int
+/* Returns the likely type of the next token, or 0 if it's hard to tell. */
+enum token_type
lex_look_ahead (struct lexer *lexer)
{
if (lexer->put_token)
break;
if (lexer->dot)
- return '.';
+ return T_ENDCMD;
else if (!lex_get_line (lexer))
return 0;
return lexer->put_token;
}
- if ((toupper ((unsigned char) *lexer->prog) == 'X'
- || toupper ((unsigned char) *lexer->prog) == 'B'
- || toupper ((unsigned char) *lexer->prog) == 'O')
- && (lexer->prog[1] == '\'' || lexer->prog[1] == '"'))
- return '\'';
+ switch (toupper ((unsigned char) *lexer->prog))
+ {
+ case 'X': case 'B': case 'O':
+ if (lexer->prog[1] == '\'' || lexer->prog[1] == '"')
+ return T_STRING;
+ /* Fall through */
+
+ case '-':
+ return T_DASH;
+
+ case '.':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ return T_POS_NUM;
+
+ case '\'': case '"':
+ return T_STRING;
+
+ case '+':
+ return T_PLUS;
+
+ case '/':
+ return T_SLASH;
+
+ case '=':
+ return T_EQUALS;
+
+ case '(':
+ return T_LPAREN;
+
+ case ')':
+ return T_RPAREN;
+
+ case '[':
+ return T_LBRACK;
+
+ case ']':
+ return T_RBRACK;
+
+ case ',':
+ return T_COMMA;
+
+ case '*':
+ return lexer->prog[1] == '*' ? T_EXP : T_ASTERISK;
- return *lexer->prog;
+ case '<':
+ return (lexer->prog[1] == '=' ? T_LE
+ : lexer->prog[1] == '>' ? T_NE
+ : T_LT);
+
+ case '>':
+ return lexer->prog[1] == '=' ? T_GE : T_GT;
+
+ case '~':
+ return lexer->prog[1] == '=' ? T_NE : T_NOT;
+
+ case '&':
+ return T_AND;
+
+ case '|':
+ return T_OR;
+
+ default:
+ if (lex_is_id1 (*lexer->prog))
+ return T_ID;
+ return 0;
+ }
}
}
/* Makes the current token become the next token to be read; the
current token is set to T. */
void
-lex_put_back (struct lexer *lexer, int t)
+lex_put_back (struct lexer *lexer, enum token_type t)
{
save_token (lexer);
lexer->token = t;
{
if (!getl_is_interactive (lexer->ss))
{
- while (lexer->token != T_STOP && lexer->token != '.')
+ while (lexer->token != T_STOP && lexer->token != T_ENDCMD)
lex_get (lexer);
}
else
&line_starts_command, &lexer->dot);
if (line_starts_command)
- lexer->put_token = '.';
+ lexer->put_token = T_ENDCMD;
lexer->prog = ds_cstr (&lexer->line_buffer);
return true;
/* Returns the name of a token. */
const char *
-lex_token_name (int token)
+lex_token_name (enum token_type token)
{
- if (lex_is_keyword (token))
- return lex_id_name (token);
- else if (token < 256)
+ switch (token)
{
- static char t[256][2];
- char *s = t[token];
- s[0] = token;
- s[1] = '\0';
- return s;
+ case T_ID:
+ case T_POS_NUM:
+ case T_NEG_NUM:
+ case T_STRING:
+ NOT_REACHED ();
+
+ case T_STOP:
+ return "";
+
+ case T_ENDCMD:
+ return ".";
+
+ case T_PLUS:
+ return "+";
+
+ case T_DASH:
+ return "-";
+
+ case T_ASTERISK:
+ return "*";
+
+ case T_SLASH:
+ return "/";
+
+ case T_EQUALS:
+ return "=";
+
+ case T_LPAREN:
+ return "(";
+
+ case T_RPAREN:
+ return ")";
+
+ case T_LBRACK:
+ return "[";
+
+ case T_RBRACK:
+ return "]";
+
+ case T_COMMA:
+ return ",";
+
+ case T_AND:
+ return "AND";
+
+ case T_OR:
+ return "OR";
+
+ case T_NOT:
+ return "NOT";
+
+ case T_EQ:
+ return "EQ";
+
+ case T_GE:
+ return ">=";
+
+ case T_GT:
+ return ">";
+
+ case T_LE:
+ return "<=";
+
+ case T_LT:
+ return "<";
+
+ case T_NE:
+ return "~=";
+
+ case T_ALL:
+ return "ALL";
+
+ case T_BY:
+ return "BY";
+
+ case T_TO:
+ return "TO";
+
+ case T_WITH:
+ return "WITH";
+
+ case T_EXP:
+ return "**";
}
- else
- NOT_REACHED ();
+
+ NOT_REACHED ();
}
/* Returns an ASCII representation of the current token as a
case T_POS_NUM:
case T_NEG_NUM:
return ds_xstrdup (&lexer->tokstr);
- break;
case T_STRING:
{
return token_rep;
}
- break;
-
- case T_STOP:
- token_rep = xmalloc (1);
- *token_rep = '\0';
- return token_rep;
-
- case T_EXP:
- return xstrdup ("**");
default:
return xstrdup (lex_token_name (lexer->token));
}
-
- NOT_REACHED ();
}
\f
/* Really weird functions. */
lexer->tokval = -lexer->tokval;
ds_assign_substring (&lexer->tokstr, ds_substr (&lexer->tokstr, 1, SIZE_MAX));
save_token (lexer);
- lexer->token = '-';
+ lexer->token = T_DASH;
}
}
return;
}
- if (lexer->put_token == '.')
+ if (lexer->put_token == T_ENDCMD)
break;
ds_cstr (&lexer->line_buffer); /* Ensures ds_end will point to a valid char */
\f
/* Token Accessor Functions */
-int
+enum token_type
lex_token (const struct lexer *lexer)
{
return lexer->token;
return lex_match_id (lexer, s);
else if (lexer->token != T_ID
|| !lex_id_match (ss_buffer (s, hyphen - s), ss_cstr (lexer->tokid))
- || lex_look_ahead (lexer) != '-')
+ || lex_look_ahead (lexer) != T_DASH)
return false;
else
{
lex_get (lexer);
- lex_force_match (lexer, '-');
+ lex_force_match (lexer, T_DASH);
lex_force_match_id (lexer, hyphen + 1);
return true;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
/* Token matching functions. */
-bool lex_match (struct lexer *, int);
+bool lex_match (struct lexer *, enum token_type);
bool lex_match_id (struct lexer *, const char *);
bool lex_match_id_n (struct lexer *, const char *, size_t n);
bool lex_match_int (struct lexer *, int);
/* Forcible matching functions. */
-bool lex_force_match (struct lexer *, int);
+bool lex_force_match (struct lexer *, enum token_type);
bool lex_force_match_id (struct lexer *, const char *);
bool lex_force_int (struct lexer *);
bool lex_force_num (struct lexer *);
bool lex_force_string (struct lexer *);
/* Weird token functions. */
-int lex_look_ahead (struct lexer *);
-void lex_put_back (struct lexer *, int);
+enum token_type lex_look_ahead (struct lexer *);
+void lex_put_back (struct lexer *, enum token_type);
void lex_put_back_id (struct lexer *, const char *tokid);
/* Weird line processing functions. */
bool lex_get_line_raw (struct lexer *);
/* Token names. */
-const char *lex_token_name (int);
+const char *lex_token_name (enum token_type);
char *lex_token_representation (struct lexer *);
/* Token accessors */
-int lex_token (const struct lexer *);
+enum token_type lex_token (const struct lexer *);
double lex_tokval (const struct lexer *);
const char *lex_tokid (const struct lexer *);
const struct string *lex_tokstr (const struct lexer *);
{
if (s->optvalue)
{
- dump (1, "if (lex_match (lexer, '('))");
+ dump (1, "if (lex_match (lexer, T_LPAREN))");
dump (1, "{");
}
else
{
- dump (1, "if (!lex_match (lexer, '('))");
+ dump (1, "if (!lex_match (lexer, T_RPAREN))");
dump (1, "{");
dump (0, "msg (SE, _(\"`(' expected after %s "
"specifier of %s subcommand.\"));",
if (s->valtype == VT_PAREN)
{
- dump (1, "if (!lex_match (lexer, ')'))");
+ dump (1, "if (!lex_match (lexer, T_RPAREN))");
dump (1, "{");
dump (0, "msg (SE, _(\"`)' expected after argument for "
"%s specifier of %s.\"));",
{
int count;
- dump (1, "while (lex_token (lexer) != '/' && lex_token (lexer) != '.')");
+ dump (1, "while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)");
dump (1, "{");
{
}
}
- dump (0, "lex_match (lexer, ',');");
+ dump (0, "lex_match (lexer, T_COMMA);");
dump (-1, "}");
outdent ();
}
}
else if (sbc->type == SBC_PINT)
{
- dump (0, "lex_match (lexer, '(');");
+ dump (0, "lex_match (lexer, T_LPAREN);");
dump (1, "if (!lex_force_int (lexer))");
dump (0, "goto lossage;");
dump (-1, "p->n_%s = lex_integer (lexer);", st_lower (sbc->name));
- dump (0, "lex_match (lexer, ')');");
+ dump (0, "lex_match (lexer, T_RPAREN);");
}
else if (sbc->type == SBC_DBL_LIST || sbc->type == SBC_INT_LIST)
{
dump (0, "goto lossage;");
dump (-1,"}");
- dump (1, "while (lex_token (lexer) != '/' && lex_token (lexer) != '.')");
+ dump (1, "while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)");
dump (1, "{");
- dump (0, "lex_match (lexer, ',');");
+ dump (0, "lex_match (lexer, T_COMMA);");
dump (0, "if (!lex_force_num (lexer))");
dump (1, "{");
dump (0, "goto lossage;");
if (def->type == SBC_VARLIST)
dump (1, "if (lex_token (lexer) == T_ID "
"&& dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) != NULL "
- "&& lex_look_ahead (lexer) != '=')");
+ "&& lex_look_ahead (lexer) != T_EQUALS)");
else
{
dump (0, "if ((lex_token (lexer) == T_ID "
"&& dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) "
- "&& lex_look_ahead () != '=')");
+ "&& lex_look_ahead () != T_EQUALS)");
dump (1, " || token == T_ALL)");
}
dump (1, "{");
f = 1;
dump (1, "{");
- dump (0, "lex_match (lexer, '=');");
+ dump (0, "lex_match (lexer, T_EQUALS);");
dump (0, "p->sbc_%s++;", st_lower (sbc->name));
if (sbc->arity != ARITY_MANY)
{
dump(1,"else if ( settings_get_syntax () != COMPATIBLE && lex_match_id(lexer, \"ALGORITHM\"))");
dump(1,"{");
- dump (0, "lex_match (lexer, '=');");
+ dump (0, "lex_match (lexer, T_EQUALS);");
dump(1,"if (lex_match_id(lexer, \"COMPATIBLE\"))");
dump(0,"settings_set_cmd_algorithm (COMPATIBLE);");
- dump (1, "if (!lex_match (lexer, '/'))");
+ dump (1, "if (!lex_match (lexer, T_SLASH))");
dump (0, "break;");
dump (-2, "}");
outdent ();
dump_blank_line (0);
- dump (1, "if (lex_token (lexer) != '.')");
+ dump (1, "if (lex_token (lexer) != T_ENDCMD)");
dump (1, "{");
dump (0, "lex_error (lexer, _(\"expecting end of command\"));");
dump (0, "goto lossage;");
if (pv_opts & PV_SINGLE)
break;
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
while (lex_token (lexer) == T_ALL
|| (lex_token (lexer) == T_ID && var_set_lookup_var (vs, lex_tokid (lexer)) != NULL));
(*names)[nvar++] = xstrdup (name1);
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
if (pv_opts & PV_SINGLE)
break;
subcase_init_empty (&agr.sort);
/* OUTFILE subcommand must be first. */
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (!lex_force_match_id (lexer, "OUTFILE"))
goto error;
- lex_match (lexer, '=');
- if (!lex_match (lexer, '*'))
+ lex_match (lexer, T_EQUALS);
+ if (!lex_match (lexer, T_ASTERISK))
{
out_file = fh_parse (lexer, FH_REF_FILE | FH_REF_SCRATCH);
if (out_file == NULL)
if (out_file == NULL && lex_match_id (lexer, "MODE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "ADDVARIABLES"))
{
agr.add_variables = true;
/* Read most of the subcommands. */
for (;;)
{
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "MISSING"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_match_id (lexer, "COLUMNWISE"))
{
lex_error (lexer, _("expecting %s"), "COLUMNWISE");
{
int i;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_sort_criteria (lexer, dict, &agr.sort, &agr.break_vars,
&saw_direction))
goto error;
"the same way as the input data."));
/* Read in the aggregate functions. */
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (!parse_aggregate_functions (lexer, dict, &agr))
goto error;
ds_init_empty (&function_name);
/* Parse the list of target variables. */
- while (!lex_match (lexer, '='))
+ while (!lex_match (lexer, T_EQUALS))
{
size_t n_dest_prev = n_dest;
lex_get (lexer);
/* Check for leading lparen. */
- if (!lex_match (lexer, '('))
+ if (!lex_match (lexer, T_LPAREN))
{
if (function->src_vars == AGR_SV_YES)
{
- lex_force_match (lexer, '(');
+ lex_force_match (lexer, T_LPAREN);
goto error;
}
}
{
int type;
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
if (lex_is_string (lexer))
{
arg[i].c = ds_xstrdup (lex_tokstr (lexer));
}
/* Trailing rparen. */
- if (!lex_force_match (lexer, ')'))
+ if (!lex_force_match (lexer, T_RPAREN))
goto error;
/* Now check that the number of source variables match
free (dest);
free (dest_label);
- if (!lex_match (lexer, '/'))
+ if (!lex_match (lexer, T_SLASH))
{
- if (lex_token (lexer) == '.')
+ if (lex_token (lexer) == T_ENDCMD)
return true;
lex_error (lexer, "expecting end of command");
/* Parse variable lists. */
lex_match_id (lexer, "VARIABLES");
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_variables_const (lexer, dict, &src_vars, &n_srcs,
PV_NO_DUPLICATE))
goto error;
if (!lex_force_match_id (lexer, "INTO"))
goto error;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_DATA_LIST_vars (lexer, &dst_names, &n_dsts, PV_NO_DUPLICATE))
goto error;
if (n_dsts != n_srcs)
}
/* Parse options. */
- while (lex_match (lexer, '/'))
+ while (lex_match (lexer, T_SLASH))
{
if (lex_match_id (lexer, "DESCENDING"))
direction = DESCENDING;
}
}
- if (lex_token (lexer) != '.')
+ if (lex_token (lexer) != T_ENDCMD)
{
lex_error (lexer, _("expecting end of command"));
goto error;
/* PSPP - a program for statistical analysis.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 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
opts.statistics = 0;
/* Parse CORRELATIONS. */
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "MISSING"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "PAIRWISE"))
opts.missing_type = CORR_PAIRWISE;
lex_error (lexer, NULL);
goto error;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
}
else if (lex_match_id (lexer, "PRINT"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if ( lex_match_id (lexer, "TWOTAIL"))
opts.tails = 2;
goto error;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
}
else if (lex_match_id (lexer, "STATISTICS"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if ( lex_match_id (lexer, "DESCRIPTIVES"))
opts.statistics = STATS_DESCRIPTIVES;
goto error;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
}
else
{
if (lex_match_id (lexer, "VARIABLES"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
}
corr = xrealloc (corr, sizeof (*corr) * (n_corrs + 1));
dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) == NULL)
&& lex_token (lexer) != T_ALL)
return 2;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (proc->variables != NULL)
var_set = const_var_set_create_from_array (proc->variables,
return 0;
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
for (;;)
{
| PV_NO_DUPLICATE | PV_NO_SCRATCH)))
return 0;
- if (!lex_force_match (lexer, '('))
+ if (!lex_force_match (lexer, T_LPAREN))
goto lossage;
if (!lex_force_int (lexer))
min = lex_integer (lexer);
lex_get (lexer);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
if (!lex_force_int (lexer))
goto lossage;
}
lex_get (lexer);
- if (!lex_force_match (lexer, ')'))
+ if (!lex_force_match (lexer, T_RPAREN))
goto lossage;
for (i = orig_nv; i < proc->n_variables; i++)
var_attach_aux (proc->variables[i], vr, var_dtor_free);
}
- if (lex_token (lexer) == '/')
+ if (lex_token (lexer) == T_SLASH)
break;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
dsc->show_stats = dsc->calc_stats = DEFAULT_STATS;
/* Parse DESCRIPTIVES. */
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
if (lex_match_id (lexer, "MISSING"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "VARIABLE"))
dsc->missing_type = DSC_VARIABLE;
lex_error (lexer, NULL);
goto error;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
}
else if (lex_match_id (lexer, "SAVE"))
save_z_scores = 1;
else if (lex_match_id (lexer, "FORMAT"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "LABELS"))
dsc->show_var_labels = 1;
lex_error (lexer, NULL);
goto error;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
}
else if (lex_match_id (lexer, "STATISTICS"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
dsc->show_stats = 0;
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match (lexer, T_ALL))
dsc->show_stats |= (1ul << DSC_N_STATS) - 1;
dsc->show_stats |= DEFAULT_STATS;
else
dsc->show_stats |= 1ul << (match_statistic (lexer));
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
if (dsc->show_stats == 0)
dsc->show_stats = DEFAULT_STATS;
}
else if (lex_match_id (lexer, "SORT"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "NAME"))
dsc->sort_by_stat = DSC_NAME;
else
if (dsc->sort_by_stat == DSC_NONE )
dsc->sort_by_stat = DSC_MEAN;
}
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
if (lex_match_id (lexer, "A"))
dsc->sort_ascending = 1;
dsc->sort_ascending = 0;
else
lex_error (lexer, NULL);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
else if (var_cnt == 0)
{
- if (lex_look_ahead (lexer) == '=')
+ if (lex_look_ahead (lexer) == T_EQUALS)
{
lex_match_id (lexer, "VARIABLES");
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
}
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
int i;
}
dsc->var_cnt = var_cnt;
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
if (lex_token (lexer) != T_ID)
{
msg (SE, _("Z-score variable name %s would be"
" a duplicate variable name."), lex_tokid (lexer));
lex_get (lexer);
- if (!lex_force_match (lexer, ')'))
+ if (!lex_force_match (lexer, T_RPAREN))
goto error;
}
}
goto error;
}
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
}
if (var_cnt == 0)
{
/* PSPP - a program for statistical analysis.
- Copyright (C) 2004, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2008, 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
xmn_custom_percentiles (struct lexer *lexer, struct dataset *ds UNUSED,
struct cmd_examine *p UNUSED, void *aux UNUSED)
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
- lex_match (lexer, '(');
+ lex_match (lexer, T_LPAREN);
while ( lex_is_number (lexer) )
{
lex_get (lexer);
- lex_match (lexer, ',') ;
+ lex_match (lexer, T_COMMA) ;
}
- lex_match (lexer, ')');
+ lex_match (lexer, T_RPAREN);
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ( lex_match_id (lexer, "HAVERAGE"))
percentile_algorithm = PC_HAVERAGE;
void *aux UNUSED)
{
const struct dictionary *dict = dataset_dict (ds);
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ( (lex_token (lexer) != T_ID || dict_lookup_var (dict, lex_tokid (lexer)) == NULL)
&& lex_token (lexer) != T_ALL)
else
ll_push_tail (&factor_list, &sf->ll);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
- if ( lex_token (lexer) == '.' || lex_token (lexer) == '/' )
+ if ( lex_token (lexer) == T_ENDCMD || lex_token (lexer) == T_SLASH )
return 1;
success = examine_parse_independent_vars (lexer, dict, cmd);
factor.wv = dict_get_weight (dict);
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (!lex_force_match_id (lexer, "VARIABLES"))
{
goto error;
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_variables_const (lexer, dict, &factor.vars, &factor.n_vars,
PV_NO_DUPLICATE | PV_NUMERIC))
if (factor.n_vars < 2)
msg (MW, _("Factor analysis on a single variable is not useful."));
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "PLOT"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "EIGEN"))
{
}
else if (lex_match_id (lexer, "METHOD"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "COVARIANCE"))
{
}
else if (lex_match_id (lexer, "ROTATION"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
/* VARIMAX and DEFAULT are defaults */
if (lex_match_id (lexer, "VARIMAX") || lex_match_id (lexer, "DEFAULT"))
}
else if (lex_match_id (lexer, "CRITERIA"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "FACTORS"))
{
- if ( lex_force_match (lexer, '('))
+ if ( lex_force_match (lexer, T_LPAREN))
{
lex_force_int (lexer);
factor.n_factors = lex_integer (lexer);
lex_get (lexer);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
else if (lex_match_id (lexer, "MINEIGEN"))
{
- if ( lex_force_match (lexer, '('))
+ if ( lex_force_match (lexer, T_LPAREN))
{
lex_force_num (lexer);
factor.min_eigen = lex_number (lexer);
lex_get (lexer);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
else if (lex_match_id (lexer, "ECONVERGE"))
{
- if ( lex_force_match (lexer, '('))
+ if ( lex_force_match (lexer, T_LPAREN))
{
lex_force_num (lexer);
factor.econverge = lex_number (lexer);
lex_get (lexer);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
else if (lex_match_id (lexer, "RCONVERGE"))
{
- if ( lex_force_match (lexer, '('))
+ if ( lex_force_match (lexer, T_LPAREN))
{
lex_force_num (lexer);
factor.rconverge = lex_number (lexer);
lex_get (lexer);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
else if (lex_match_id (lexer, "ITERATE"))
{
- if ( lex_force_match (lexer, '('))
+ if ( lex_force_match (lexer, T_LPAREN))
{
lex_force_int (lexer);
factor.iterations = lex_integer (lexer);
lex_get (lexer);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
else if (lex_match_id (lexer, "DEFAULT"))
else if (lex_match_id (lexer, "EXTRACTION"))
{
extraction_seen = true;
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "PAF"))
{
}
else if (lex_match_id (lexer, "FORMAT"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "SORT"))
{
}
else if (lex_match_id (lexer, "BLANK"))
{
- if ( lex_force_match (lexer, '('))
+ if ( lex_force_match (lexer, T_LPAREN))
{
lex_force_num (lexer);
factor.blank = lex_number (lexer);
lex_get (lexer);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
else if (lex_match_id (lexer, "DEFAULT"))
else if (lex_match_id (lexer, "PRINT"))
{
factor.print = 0;
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "UNIVARIATE"))
{
}
else if (lex_match_id (lexer, "MISSING"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "INCLUDE"))
{
flip->error = false;
flip->dict = dict;
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "VARIABLES"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_variables_const (lexer, dict, &vars, &flip->n_vars,
PV_NO_DUPLICATE))
goto error;
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
}
else
dict_get_vars (dict, &vars, &flip->n_vars, DC_SYSTEM);
pool_register (flip->pool, free, vars);
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "NEWNAMES"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
flip->new_names_var = parse_variable (lexer, dict);
if (!flip->new_names_var)
goto error;
size_t n_vars;
size_t i;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_token (lexer) != T_ALL
&& (lex_token (lexer) != T_ID
|| dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) == NULL))
{
struct frq_proc *frq = frq_;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ((lex_token (lexer) == T_ID && dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) != NULL)
|| lex_token (lexer) == T_ID)
for (;;)
if (!parse_variables_const (lexer, dataset_dict (ds), &v, &n,
PV_NO_DUPLICATE | PV_NUMERIC))
return 0;
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
nl = ml = 0;
dl = NULL;
}
dl[nl++] = lex_tokval (lexer);
lex_get (lexer);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
/* Note that nl might still be 0 and dl might still be
NULL. That's okay. */
- if (!lex_match (lexer, ')'))
+ if (!lex_match (lexer, T_RPAREN))
{
free (v);
msg (SE, _("`)' expected after GROUPED interval list."));
}
free (v);
- if (!lex_match (lexer, '/'))
+ if (!lex_match (lexer, T_SLASH))
break;
if ((lex_token (lexer) != T_ID || dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) != NULL)
&& lex_token (lexer) != T_ALL)
{
- lex_put_back (lexer, '/');
+ lex_put_back (lexer, T_SLASH);
break;
}
}
struct const_var_set *factors = const_var_set_create_from_array (glm.factor_vars, glm.n_factor_vars);
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "MISSING"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "INCLUDE"))
{
}
else if (lex_match_id (lexer, "INTERCEPT"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "INCLUDE"))
{
{
size_t n_des;
const struct variable **des;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
parse_const_var_set_vars (lexer, factors, &des, &n_des, 0);
}
}
else if (lex_match_hyphenated_word (lexer, "CHISQUARE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
npt->chisquare++;
switch (npar_chisquare (lexer, ds, nps))
{
}
else if (lex_match_hyphenated_word (lexer, "BINOMIAL"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
npt->binomial++;
switch (npar_binomial (lexer, ds, nps))
{
else if (lex_match_hyphenated_word (lexer, "K-W") ||
lex_match_hyphenated_word (lexer, "KRUSKAL-WALLIS"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
npt->kruskal_wallis++;
switch (npar_kruskal_wallis (lexer, ds, nps))
{
}
else if (lex_match_hyphenated_word (lexer, "WILCOXON"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
npt->wilcoxon++;
switch (npar_wilcoxon (lexer, ds, nps))
{
}
else if (lex_match_hyphenated_word (lexer, "SIGN"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
npt->sign++;
switch (npar_sign (lexer, ds, nps))
{
}
else if (lex_match_hyphenated_word (lexer, "MISSING"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
npt->missing++;
if (npt->missing > 1)
{
msg (SE, _("The %s subcommand may be given only once."), "MISSING");
goto lossage;
}
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
{
if (lex_match_hyphenated_word (lexer, "ANALYSIS"))
npt->miss = MISS_ANALYSIS;
lex_error (lexer, NULL);
goto lossage;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
}
else if (lex_match_hyphenated_word (lexer, "METHOD"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
npt->method++;
if (npt->method > 1)
{
}
else if (lex_match_hyphenated_word (lexer, "STATISTICS"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
npt->statistics++;
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
{
if (lex_match_hyphenated_word (lexer, "DESCRIPTIVES"))
npt->a_statistics[NPAR_ST_DESCRIPTIVES] = 1;
lex_error (lexer, NULL);
goto lossage;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
}
else if ( settings_get_syntax () != COMPATIBLE && lex_match_id (lexer, "ALGORITHM"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "COMPATIBLE"))
settings_set_cmd_algorithm (COMPATIBLE);
else if (lex_match_id (lexer, "ENHANCED"))
settings_set_cmd_algorithm (ENHANCED);
}
- if (!lex_match (lexer, '/'))
+ if (!lex_match (lexer, T_SLASH))
break;
}
- if (lex_token (lexer) != '.')
+ if (lex_token (lexer) != T_ENDCMD)
{
lex_error (lexer, _("expecting end of command"));
goto lossage;
cstp->ranged = false;
- if ( lex_match (lexer, '('))
+ if ( lex_match (lexer, T_LPAREN))
{
cstp->ranged = true;
if ( ! lex_force_num (lexer)) return 0;
cstp->lo = lex_integer (lexer);
lex_get (lexer);
- lex_force_match (lexer, ',');
+ lex_force_match (lexer, T_COMMA);
if (! lex_force_num (lexer) ) return 0;
cstp->hi = lex_integer (lexer);
if ( cstp->lo >= cstp->hi )
return 0;
}
lex_get (lexer);
- if (! lex_force_match (lexer, ')')) return 0;
+ if (! lex_force_match (lexer, T_RPAREN)) return 0;
}
cstp->n_expected = 0;
cstp->expected = NULL;
- if ( lex_match (lexer, '/') )
+ if ( lex_match (lexer, T_SLASH) )
{
if ( lex_match_id (lexer, "EXPECTED") )
{
- lex_force_match (lexer, '=');
+ lex_force_match (lexer, T_EQUALS);
if ( ! lex_match_id (lexer, "EQUAL") )
{
double f;
f = lex_number (lexer);
lex_get (lexer);
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
cstp->n_expected += n;
cstp->expected = pool_realloc (specs->pool,
}
}
else
- lex_put_back (lexer, '/');
+ lex_put_back (lexer, T_SLASH);
}
if ( cstp->ranged && cstp->n_expected > 0 &&
btp->p = 0.5;
- if ( lex_match (lexer, '(') )
+ if ( lex_match (lexer, T_LPAREN) )
{
if ( lex_force_num (lexer) )
{
btp->p = lex_number (lexer);
lex_get (lexer);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
else
return 0;
}
else
/* Kludge: q2c swallows the '=' so put it back here */
- lex_put_back (lexer, '=');
+ lex_put_back (lexer, T_EQUALS);
- if (lex_match (lexer, '=') )
+ if (lex_match (lexer, T_EQUALS) )
{
if (parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds),
&tp->vars, &tp->n_vars,
PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
{
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
lex_force_num (lexer);
btp->category1 = lex_number (lexer);
lex_get (lexer);
- if ( lex_match (lexer, ','))
+ if ( lex_match (lexer, T_COMMA))
{
if ( ! lex_force_num (lexer) ) return 2;
btp->category2 = lex_number (lexer);
btp->cutpoint = btp->category1;
}
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
else
PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
return false;
- paired = (lex_match (lexer, '(') &&
- lex_match_id (lexer, "PAIRED") && lex_match (lexer, ')'));
+ paired = (lex_match (lexer, T_LPAREN) &&
+ lex_match_id (lexer, "PAIRED") && lex_match (lexer, T_RPAREN));
}
nst->indep_var = parse_variable_const (lexer, dict);
- if ( ! lex_force_match (lexer, '('))
+ if ( ! lex_force_match (lexer, T_LPAREN))
return false;
value_init (&nst->val1, var_get_width (nst->indep_var));
return false;
}
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
value_init (&nst->val2, var_get_width (nst->indep_var));
if ( ! parse_value (lexer, &nst->val2, var_get_width (nst->indep_var)))
return false;
}
- if ( ! lex_force_match (lexer, ')'))
+ if ( ! lex_force_match (lexer, T_RPAREN))
return false;
return true;
{
specs->timer = 5.0;
- if ( lex_match (lexer, '('))
+ if ( lex_match (lexer, T_LPAREN))
{
if ( lex_force_num (lexer) )
{
specs->timer = lex_number (lexer);
lex_get (lexer);
}
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
}
ll_init (&oneway.contrast_list);
- if ( lex_match (lexer, '/'))
+ if ( lex_match (lexer, T_SLASH))
{
if (!lex_force_match_id (lexer, "VARIABLES"))
{
goto error;
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
}
if (!parse_variables_const (lexer, dict,
oneway.indep_var = parse_variable_const (lexer, dict);
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "STATISTICS"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "DESCRIPTIVES"))
{
struct contrasts_node *cl = xzalloc (sizeof *cl);
struct ll_list *coefficient_list = &cl->coefficient_list;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
ll_init (coefficient_list);
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if ( lex_is_number (lexer))
{
}
else if (lex_match_id (lexer, "MISSING"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "INCLUDE"))
{
/* PSPP - a program for statistical analysis.
- Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, 2007, 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
static int
rank_custom_variables (struct lexer *lexer, struct dataset *ds, struct cmd_rank *cmd UNUSED, void *aux UNUSED)
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ((lex_token (lexer) != T_ID || dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) == NULL)
&& lex_token (lexer) != T_ALL)
{
struct dictionary *dict = dataset_dict (ds);
- if ( lex_force_match (lexer, '(') )
+ if ( lex_force_match (lexer, T_LPAREN) )
{
if ( lex_force_int (lexer) )
{
k_ntiles = lex_integer (lexer);
lex_get (lexer);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
else
return 0;
/* 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
{
const struct dictionary *dict = dataset_dict (ds);
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ((lex_token (lexer) != T_ID
|| dict_lookup_var (dict, lex_tokid (lexer)) == NULL)
reliability.total_start = 0;
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (!lex_force_match_id (lexer, "VARIABLES"))
{
goto error;
}
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_variables_const (lexer, dict, &reliability.variables, &reliability.n_variables,
PV_NO_DUPLICATE | PV_NUMERIC))
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "SCALE"))
{
struct const_var_set *vs;
- if ( ! lex_force_match (lexer, '('))
+ if ( ! lex_force_match (lexer, T_LPAREN))
goto error;
if ( ! lex_force_string (lexer) )
lex_get (lexer);
- if ( ! lex_force_match (lexer, ')'))
+ if ( ! lex_force_match (lexer, T_RPAREN))
goto error;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
vs = const_var_set_create_from_array (reliability.variables, reliability.n_variables);
}
else if (lex_match_id (lexer, "MODEL"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "ALPHA"))
{
reliability.model = MODEL_ALPHA;
reliability.model = MODEL_SPLIT;
reliability.split_point = -1;
- if ( lex_match (lexer, '('))
+ if ( lex_match (lexer, T_LPAREN))
{
lex_force_num (lexer);
reliability.split_point = lex_number (lexer);
lex_get (lexer);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
else
}
else if (lex_match_id (lexer, "SUMMARY"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "TOTAL"))
{
reliability.summary |= SUMMARY_TOTAL;
}
else if (lex_match_id (lexer, "MISSING"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "INCLUDE"))
{
/* PSPP - a program for statistical analysis.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 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
roc.dict = dataset_dict (ds);
roc.state_var = NULL;
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (!parse_variables_const (lexer, dict, &roc.vars, &roc.n_vars,
PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC))
goto error;
roc.state_var = parse_variable (lexer, dict);
- if ( !lex_force_match (lexer, '('))
+ if ( !lex_force_match (lexer, T_LPAREN))
{
goto error;
}
parse_value (lexer, &roc.state_value, var_get_width (roc.state_var));
- if ( !lex_force_match (lexer, ')'))
+ if ( !lex_force_match (lexer, T_RPAREN))
{
goto error;
}
- while (lex_token (lexer) != '.')
+ while (lex_token (lexer) != T_ENDCMD)
{
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "MISSING"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "INCLUDE"))
{
}
else if (lex_match_id (lexer, "PLOT"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "CURVE"))
{
roc.curve = true;
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
roc.reference = true;
lex_force_match_id (lexer, "REFERENCE");
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
}
else if (lex_match_id (lexer, "NONE"))
}
else if (lex_match_id (lexer, "PRINT"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "SE"))
{
}
else if (lex_match_id (lexer, "CRITERIA"))
{
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
if (lex_match_id (lexer, "CUTOFF"))
{
- lex_force_match (lexer, '(');
+ lex_force_match (lexer, T_LPAREN);
if (lex_match_id (lexer, "INCLUDE"))
{
roc.exclude = MV_SYSTEM;
lex_error (lexer, NULL);
goto error;
}
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
else if (lex_match_id (lexer, "TESTPOS"))
{
- lex_force_match (lexer, '(');
+ lex_force_match (lexer, T_LPAREN);
if (lex_match_id (lexer, "LARGE"))
{
roc.invert = false;
lex_error (lexer, NULL);
goto error;
}
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
else if (lex_match_id (lexer, "CI"))
{
- lex_force_match (lexer, '(');
+ lex_force_match (lexer, T_LPAREN);
lex_force_num (lexer);
roc.ci = lex_number (lexer);
lex_get (lexer);
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
else if (lex_match_id (lexer, "DISTRIBUTION"))
{
- lex_force_match (lexer, '(');
+ lex_force_match (lexer, T_LPAREN);
if (lex_match_id (lexer, "FREE"))
{
roc.bi_neg_exp = false;
lex_error (lexer, NULL);
goto error;
}
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
}
else
{
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
if (!parse_sort_criteria (lexer, dataset_dict (ds), &ordering, NULL, NULL))
return CMD_CASCADING_FAILURE;
- if (settings_get_testing_mode () && lex_match (lexer, '/'))
+ if (settings_get_testing_mode () && lex_match (lexer, T_SLASH))
{
- if (!lex_force_match_id (lexer, "BUFFERS") || !lex_match (lexer, '=')
+ if (!lex_force_match_id (lexer, "BUFFERS") || !lex_match (lexer, T_EQUALS)
|| !lex_force_int (lexer))
goto done;
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 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
goto error;
/* Sort direction. */
- if (lex_match (lexer, '('))
+ if (lex_match (lexer, T_LPAREN))
{
if (lex_match_id (lexer, "D") || lex_match_id (lexer, "DOWN"))
direction = SC_DESCEND;
msg (SE, _("`A' or `D' expected inside parentheses."));
goto error;
}
- if (!lex_match (lexer, ')'))
+ if (!lex_match (lexer, T_RPAREN))
{
msg (SE, _("`)' expected."));
goto error;
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
int n_values;
int width;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
proc->indep_var = parse_variable (lexer, dataset_dict (ds));
if (proc->indep_var == NULL)
value_init (&proc->g_value[0], width);
value_init (&proc->g_value[1], width);
- if (!lex_match (lexer, '('))
+ if (!lex_match (lexer, T_LPAREN))
n_values = 0;
else
{
if (!parse_value (lexer, &proc->g_value[0], width))
return 0;
- lex_match (lexer, ',');
- if (lex_match (lexer, ')'))
+ lex_match (lexer, T_COMMA);
+ if (lex_match (lexer, T_RPAREN))
n_values = 1;
else
{
if (!parse_value (lexer, &proc->g_value[1], width)
- || !lex_force_match (lexer, ')'))
+ || !lex_force_match (lexer, T_RPAREN))
return 0;
n_values = 2;
}
size_t n_total_pairs;
size_t i, j;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_variables_const (lexer, dataset_dict (ds), &vars1, &n_vars1,
PV_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH))
return 0;
}
- if (lex_match (lexer, '(')
+ if (lex_match (lexer, T_LPAREN)
&& lex_match_id (lexer, "PAIRED")
- && lex_match (lexer, ')'))
+ && lex_match (lexer, T_RPAREN))
{
paired = true;
if (n_vars1 != n_vars2)
/* PSPP - a program for statistical analysis.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 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
size_t length;
if (!parse_float_format (lexer, &fp->format)
- || !lex_force_match (lexer, '(')
+ || !lex_force_match (lexer, T_LPAREN)
|| !lex_force_string (lexer))
return false;
}
lex_get (lexer);
- if (!lex_force_match (lexer, ')'))
+ if (!lex_force_match (lexer, T_RPAREN))
return false;
}
else
if (!parse_fp (lexer, &fp[fp_cnt++]))
return CMD_FAILURE;
- if (lex_token (lexer) == '.' && fp_cnt > 1)
+ if (lex_token (lexer) == T_ENDCMD && fp_cnt > 1)
break;
- else if (!lex_force_match (lexer, '='))
+ else if (!lex_force_match (lexer, T_EQUALS))
return CMD_FAILURE;
if (fp_cnt == 1)
{
- if (lex_match (lexer, '='))
+ if (lex_match (lexer, T_EQUALS))
bijective = true;
else if (lex_match (lexer, T_GT))
bijective = false;
}
else
{
- if ((bijective && !lex_force_match (lexer, '='))
+ if ((bijective && !lex_force_match (lexer, T_EQUALS))
|| (!bijective && !lex_force_match (lexer, T_GT)))
return CMD_FAILURE;
}
double value = lex_tokval (lexer);
double weight = 1.;
lex_get (lexer);
- if (lex_match (lexer, '*'))
+ if (lex_match (lexer, T_ASTERISK))
{
if (!lex_is_number (lexer))
{
if (lex_match_id (lexer, "ONEPASS"))
two_pass = 0;
- if (lex_token (lexer) != '/')
+ if (lex_token (lexer) != T_SLASH)
{
- lex_force_match (lexer, '/');
+ lex_force_match (lexer, T_SLASH);
goto done;
}
lex_get (lexer);
return CMD_FAILURE;
}
- if (lex_token (lexer) == '.')
+ if (lex_token (lexer) == T_ENDCMD)
return shell () ? CMD_SUCCESS : CMD_FAILURE;
else if (lex_match_id (lexer, "COMMAND"))
{
struct string command;
bool ok;
- lex_match (lexer, '=');
- if (!lex_force_match (lexer, '['))
+ lex_match (lexer, T_EQUALS);
+ if (!lex_force_match (lexer, T_LBRACK))
return CMD_FAILURE;
ds_init_empty (&command);
ds_put_substring (&command, ds_ss (lex_tokstr (lexer)));
lex_get (lexer);
}
- if (!lex_force_match (lexer, ']'))
+ if (!lex_force_match (lexer, T_RBRACK))
{
ds_destroy (&command);
return CMD_FAILURE;
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007, 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
lex_get (lexer);
- while ( '.' != lex_token (lexer))
+ while ( T_ENDCMD != lex_token (lexer))
{
if (lex_match_id (lexer, "SYNTAX"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ( lex_match_id (lexer, "INTERACTIVE") )
syntax_mode = GETL_INTERACTIVE;
else if ( lex_match_id (lexer, "BATCH"))
}
else if (lex_match_id (lexer, "CD"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ( lex_match_id (lexer, "YES") )
{
cd = true;
}
else if (lex_match_id (lexer, "ERROR"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ( lex_match_id (lexer, "CONTINUE") )
{
error_mode = ERRMODE_CONTINUE;
/* Skip optional FILE=. */
if (lex_match_id (lexer, "FILE"))
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
/* File name can be identifier or string. */
if (lex_token (lexer) != T_ID && !lex_is_string (lexer))
{
char *fn = 0;
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "FILE"))
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
return CMD_FAILURE;
lex_force_match (lexer, T_STRING);
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
if ( ! lex_match_id (lexer, "PERMISSIONS"))
goto error;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ( lex_match_id (lexer, "READONLY"))
{
{
enum settings_output_devices devices;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "ON") || lex_match_id (lexer, "BOTH"))
devices = SETTINGS_DEVICE_LISTING | SETTINGS_DEVICE_TERMINAL;
else if (lex_match_id (lexer, "TERMINAL"))
struct dataset *ds UNUSED,
struct cmd_set *cmd UNUSED, void *aux UNUSED)
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "SYSMIS"))
{
lex_get (lexer);
struct dataset *ds UNUSED,
struct cmd_set *cmd UNUSED, void *aux UNUSED)
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "AUTOMATIC"))
settings_set_epoch (-1);
else if (lex_is_integer (lexer))
{
int page_length;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "NONE"))
page_length = -1;
else
{
const struct string *s;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ( !lex_force_string (lexer))
return 0;
static int
stc_custom_seed (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "RANDOM"))
set_rng (time (0));
else
static int
stc_custom_width (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "NARROW"))
settings_set_viewwidth (79);
else if (lex_match_id (lexer, "WIDE"))
{
struct fmt_spec fmt;
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (!parse_format_specifier (lexer, &fmt))
return 0;
static int
stc_custom_journal (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "ON") || lex_match_id (lexer, "YES"))
journal_enable ();
else if (lex_match_id (lexer, "OFF") || lex_match_id (lexer, "NO"))
int
cmd_show (struct lexer *lexer, struct dataset *ds)
{
- if (lex_token (lexer) == '.')
+ if (lex_token (lexer) == T_ENDCMD)
{
show_all (ds);
return CMD_SUCCESS;
return CMD_FAILURE;
}
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
}
- while (lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_ENDCMD);
return CMD_SUCCESS;
}
static int
parse_title (struct lexer *lexer, enum text_item_type type)
{
- int c;
-
- c = lex_look_ahead (lexer);
- if (c == '"' || c == '\'')
+ if (lex_look_ahead (lexer) == T_STRING)
{
lex_get (lexer);
if (!lex_force_string (lexer))
if (lvalue == NULL)
goto fail;
- if (!lex_force_match (lexer, '='))
+ if (!lex_force_match (lexer, T_EQUALS))
goto fail;
compute->rvalue = parse_rvalue (lexer, lvalue, ds);
if (compute->rvalue == NULL)
goto fail;
/* Rvalue expression. */
- if (!lex_force_match (lexer, '='))
+ if (!lex_force_match (lexer, T_EQUALS))
goto fail;
compute->rvalue = parse_rvalue (lexer, lvalue, ds);
if (compute->rvalue == NULL)
if (!lex_force_id (lexer))
goto lossage;
- if (lex_look_ahead (lexer) == '(')
+ if (lex_look_ahead (lexer) == T_LPAREN)
{
/* Vector. */
lvalue->vector = dict_lookup_vector (dict, lex_tokid (lexer));
/* Vector element. */
lex_get (lexer);
- if (!lex_force_match (lexer, '('))
+ if (!lex_force_match (lexer, T_LPAREN))
goto lossage;
lvalue->element = expr_parse (lexer, ds, EXPR_NUMBER);
if (lvalue->element == NULL)
goto lossage;
- if (!lex_force_match (lexer, ')'))
+ if (!lex_force_match (lexer, T_RPAREN))
goto lossage;
}
else
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
dv->name = pool_strdup (trns->pool, lex_tokid (lexer));
lex_get (lexer);
- if (!lex_force_match (lexer, '='))
+ if (!lex_force_match (lexer, T_EQUALS))
goto fail;
crit = dv->crit = pool_alloc (trns->pool, sizeof *crit);
goto fail;
pool_register (trns->pool, free, crit->vars);
- if (!lex_force_match (lexer, '('))
+ if (!lex_force_match (lexer, T_LPAREN))
goto fail;
crit->value_cnt = 0;
if (!ok)
goto fail;
- if (lex_token (lexer) == '/' || lex_token (lexer) == '.')
+ if (lex_token (lexer) == T_SLASH || lex_token (lexer) == T_ENDCMD)
break;
crit = crit->next = pool_alloc (trns->pool, sizeof *crit);
}
- if (lex_token (lexer) == '.')
+ if (lex_token (lexer) == T_ENDCMD)
break;
- if (!lex_force_match (lexer, '/'))
+ if (!lex_force_match (lexer, T_SLASH))
goto fail;
dv = dv->next = pool_alloc (trns->pool, sizeof *dv);
}
else
return false;
- lex_match (lexer, ',');
- if (lex_match (lexer, ')'))
+ lex_match (lexer, T_COMMA);
+ if (lex_match (lexer, T_RPAREN))
break;
}
return true;
str_copy_rpad (*cur, len + 1, ds_cstr (lex_tokstr (lexer)));
lex_get (lexer);
- lex_match (lexer, ',');
- if (lex_match (lexer, ')'))
+ lex_match (lexer, T_COMMA);
+ if (lex_match (lexer, T_RPAREN))
break;
}
add_transformation (ds,
recode_trns_proc, recode_trns_free, trns);
}
- while (lex_match (lexer, '/'));
+ while (lex_match (lexer, T_SLASH));
return lex_end_of_command (lexer);
}
trns->map_cnt = 0;
map_allocated = 0;
have_dst_type = false;
- if (!lex_force_match (lexer, '('))
+ if (!lex_force_match (lexer, T_LPAREN))
return false;
do
{
trns->src_type, trns->max_src_width))
return false;
add_mapping (trns, &map_allocated, &in);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
- while (!lex_match (lexer, '='));
+ while (!lex_match (lexer, T_EQUALS));
if (!parse_map_out (lexer, trns->pool, &out))
return false;
trns->dst_type = dst_type;
have_dst_type = true;
- if (!lex_force_match (lexer, ')'))
+ if (!lex_force_match (lexer, T_RPAREN))
return false;
}
- while (lex_match (lexer, '('));
+ while (lex_match (lexer, T_LPAREN));
return true;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
if (!e)
return CMD_CASCADING_FAILURE;
- if (lex_token (lexer) != '.')
+ if (lex_token (lexer) != T_ENDCMD)
{
expr_free (e);
lex_error (lexer, _("expecting end of command"));
struct dictionary *dict = dataset_dict (ds);
if (lex_match_id (lexer, "OFF"))
dict_set_filter (dict, NULL);
- else if (lex_token (lexer) == '.')
+ else if (lex_token (lexer) == T_ENDCMD)
{
msg (SW, _("Syntax error expecting OFF or BY. "
"Turning off case filtering."));
[['asdfj ' ne 'asdf'], [true]],
dnl <> token can't be split:
[[1 < > 1], [error],
- [error: DEBUG EVALUATE: Syntax error at `GT'.]],
+ [error: DEBUG EVALUATE: Syntax error at `>'.]],
dnl # ~= token can't be split:
[[1 ~ = 1], [error],
[error: DEBUG EVALUATE: Syntax error at `NOT': expecting end of command.]])