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);
else if (lex_match_id (lexer, "PSQL"))
return parse_get_psql (lexer, ds);
- msg (SE, _("Unsupported TYPE %s"), lex_tokid (lexer));
+ msg (SE, _("Unsupported TYPE %s."), lex_tokcstr (lexer));
return CMD_FAILURE;
}
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;
- psql.conninfo = xstrdup (ds_cstr (lex_tokstr (lexer)));
+ psql.conninfo = ss_xstrdup (lex_tokss (lexer));
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;
- ds_put_substring (&psql.sql, lex_tokstr (lexer)->ss);
+ ds_put_substring (&psql.sql, lex_tokss (lexer));
lex_get (lexer);
}
}
{
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;
- gri.file_name = xstrdup (ds_cstr (lex_tokstr (lexer)));
+ gri.file_name = ss_xstrdup (lex_tokss (lexer));
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) )
goto error;
- gri.sheet_name = xstrdup (ds_cstr (lex_tokstr (lexer)));
+ gri.sheet_name = ss_xstrdup (lex_tokss (lexer));
gri.sheet_index = -1;
}
else if (lex_match_id (lexer, "INDEX"))
}
else if (lex_match_id (lexer, "CELLRANGE"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "FULL"))
{
if ( ! lex_force_string (lexer) )
goto error;
- gri.cell_range = xstrdup (ds_cstr (lex_tokstr (lexer)));
+ gri.cell_range = ss_xstrdup (lex_tokss (lexer));
}
else
goto error;
}
else if (lex_match_id (lexer, "READNAMES"))
{
- lex_match (lexer, '=');
+ lex_match (lexer, T_EQUALS);
if ( lex_match_id (lexer, "ON"))
{
}
else
{
+ printf ("Unknown data file type `%s'\n", lex_tokcstr (lexer));
goto error;
}
lex_get (lexer);
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;
- s = ds_ss (lex_tokstr (lexer));
+ s = lex_tokss (lexer);
if (ss_match_string (&s, ss_cstr ("\\t")))
ds_put_cstr (&hard_seps, "\t");
if (ss_match_string (&s, ss_cstr ("\\\\")))
ds_put_cstr (&hard_seps, "\\");
- while ((c = ss_get_char (&s)) != EOF)
+ while ((c = ss_get_byte (&s)) != EOF)
if (c == ' ')
soft_seps = " ";
else
- ds_put_char (&hard_seps, c);
+ ds_put_byte (&hard_seps, c);
data_parser_set_soft_delimiters (parser, ss_cstr (soft_seps));
data_parser_set_hard_delimiters (parser, ds_ss (&hard_seps));
ds_destroy (&hard_seps);
{
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;
if (settings_get_syntax () == COMPATIBLE
- && ds_length (lex_tokstr (lexer)) != 1)
+ && ss_length (lex_tokss (lexer)) != 1)
{
msg (SE, _("In compatible syntax mode, the QUALIFIER string "
"must contain exactly one character."));
goto error;
}
- data_parser_set_quotes (parser, ds_ss (lex_tokstr (lexer)));
+ data_parser_set_quotes (parser, lex_tokss (lexer));
lex_get (lexer);
}
else if (settings_get_syntax () == ENHANCED
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;
if (!lex_force_id (lexer))
goto error;
- strcpy (name, lex_tokid (lexer));
+ strcpy (name, lex_tokcstr (lexer));
lex_get (lexer);
if (type == DP_DELIMITED)
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)