Patch #5676 (syntax string source).
[pspp-builds.git] / src / ui / gui / helper.c
index 75b88f1d8ba5f63d972b9a21304af3fedea7c50d..4d88c81bde63bb98db897631738e1100ee2e0734 100644 (file)
@@ -1,8 +1,14 @@
+/* This file is a rubbish bin where stuff gets put when it doesn't seem to
+   belong anywhere else.
+*/
 #include <config.h>
 
+#include <glib.h>
 #include "helper.h"
+#include "message-dialog.h"
 #include <data/data-in.h>
 #include <data/data-out.h>
+#include <data/dictionary.h>
 #include <libpspp/message.h>
 
 #include <libpspp/i18n.h>
 #include <string.h>
 #include <data/settings.h>
 
+#include <language/command.h>
+#include <data/procedure.h>
+#include <language/lexer/lexer.h>
+
+
+#include <gettext.h>
+
 /* Formats a value according to FORMAT
    The returned string must be freed when no longer required */
 gchar *
@@ -113,3 +126,47 @@ connect_help (GladeXML *xml)
 }
 
 
+
+void
+reference_manual (GtkMenuItem *menu, gpointer data)
+{
+  GError *err = NULL;
+  if ( ! g_spawn_command_line_async ("yelp info:pspp", &err) )
+    {
+      msg (ME, _("Cannot open reference manual: %s"), err->message);
+    }
+  g_clear_error (&err);
+}
+
+
+extern struct dataset *the_dataset;
+extern struct source_stream *the_source_stream;
+
+void
+execute_syntax (struct getl_interface *sss)
+{
+  struct lexer *lexer;
+  g_return_if_fail (proc_has_source (the_dataset));
+
+  lexer = lex_create (the_source_stream);
+
+  getl_append_source (the_source_stream, sss);
+
+  for (;;)
+    {
+      const struct dictionary *dict = dataset_dict (the_dataset);
+
+      int result = cmd_parse (lexer, the_dataset,
+                             dict_get_var_cnt (dict) > 0 ?
+                             CMD_STATE_DATA : CMD_STATE_INITIAL);
+
+      if (result == CMD_EOF || result == CMD_FINISH)
+       break;
+    }
+
+  getl_abort_noninteractive (the_source_stream);
+
+  lex_destroy (lexer);
+}
+
+