+cmd_include (struct lexer *lexer, struct dataset *ds UNUSED)
+{
+ char *filename = NULL;
+ int status = parse_insert (lexer, &filename);
+
+ if ( CMD_SUCCESS != status)
+ return status;
+
+ lex_get (lexer);
+
+ status = lex_end_of_command (lexer);
+
+ if ( status == CMD_SUCCESS)
+ {
+ struct source_stream *ss = lex_get_source_stream (lexer);
+
+ assert (filename);
+ getl_include_source (ss, create_syntax_file_source (filename),
+ GETL_BATCH, ERRMODE_STOP);
+ free (filename);
+ }
+
+ return status;
+}
+
+
+int
+cmd_insert (struct lexer *lexer, struct dataset *ds UNUSED)
+{
+ enum syntax_mode syntax_mode = GETL_INTERACTIVE;
+ enum error_mode error_mode = ERRMODE_CONTINUE;
+ char *filename = NULL;
+ int status = parse_insert (lexer, &filename);
+ bool cd = false;
+
+ if ( CMD_SUCCESS != status)
+ return status;
+
+ lex_get (lexer);
+
+ while ( T_ENDCMD != lex_token (lexer))
+ {
+ if (lex_match_id (lexer, "SYNTAX"))
+ {
+ lex_match (lexer, T_EQUALS);
+ if ( lex_match_id (lexer, "INTERACTIVE") )
+ syntax_mode = GETL_INTERACTIVE;
+ else if ( lex_match_id (lexer, "BATCH"))
+ syntax_mode = GETL_BATCH;
+ else
+ {
+ lex_error (lexer, _("expecting %s or %s after %s"),
+ "BATCH", "INTERACTIVE", "SYNTAX");
+ return CMD_FAILURE;
+ }
+ }
+ else if (lex_match_id (lexer, "CD"))
+ {
+ lex_match (lexer, T_EQUALS);
+ if ( lex_match_id (lexer, "YES") )
+ {
+ cd = true;
+ }
+ else if ( lex_match_id (lexer, "NO"))
+ {
+ cd = false;
+ }
+ else
+ {
+ lex_error (lexer, _("expecting %s or %s after %s"),
+ "YES", "NO", "CD");
+ return CMD_FAILURE;
+ }
+ }
+ else if (lex_match_id (lexer, "ERROR"))
+ {
+ lex_match (lexer, T_EQUALS);
+ if ( lex_match_id (lexer, "CONTINUE") )
+ {
+ error_mode = ERRMODE_CONTINUE;
+ }
+ else if ( lex_match_id (lexer, "STOP"))
+ {
+ error_mode = ERRMODE_STOP;
+ }
+ else
+ {
+ lex_error (lexer, _("expecting %s or %s after %s"),
+ "CONTINUE", "STOP", "ERROR");
+ return CMD_FAILURE;
+ }
+ }
+
+ else
+ {
+ lex_error (lexer, _("Unexpected token: `%s'."),
+ lex_token_representation (lexer));
+
+ return CMD_FAILURE;
+ }
+ }
+
+ status = lex_end_of_command (lexer);
+
+ if ( status == CMD_SUCCESS)
+ {
+ struct source_stream *ss = lex_get_source_stream (lexer);
+
+ assert (filename);
+ getl_include_source (ss, create_syntax_file_source (filename),
+ syntax_mode,
+ error_mode);
+
+ if ( cd )
+ {
+ char *directory = dir_name (filename);
+ chdir (directory);
+ free (directory);
+ }
+
+ free (filename);
+ }
+
+ return status;
+}
+
+
+static int
+parse_insert (struct lexer *lexer, char **filename)