Encapsulated lexer and updated calling functions accordingly.
[pspp] / src / ui / terminal / main.c
index 6a7decd9d95d77192488ba0ba66ea8a2b0266154..0613476b549f88027e431170b18b1c640a2bedac 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - computes sample statistics.
-   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
    Written by Ben Pfaff <blp@gnu.org>.
 
    This program is free software; you can redistribute it and/or
@@ -30,6 +30,7 @@
 #include <data/dictionary.h>
 #include <data/file-handle-def.h>
 #include <data/file-name.h>
+#include <data/format.h>
 #include <data/procedure.h>
 #include <data/settings.h>
 #include <data/variable.h>
@@ -71,7 +72,7 @@ void bug_handler(int sig);
 void interrupt_handler(int sig);
 static struct dataset * the_dataset = NULL;
 
-
+static struct lexer *the_lexer;
 
 /* Program entry point. */
 int
@@ -87,8 +88,8 @@ main (int argc, char **argv)
   fpu_init ();
   gsl_set_error_handler_off ();
 
+  fmt_init ();
   outp_init ();
-  msg_ui_init ();
   fn_init ();
   fh_init ();
   getl_initialize ();
@@ -99,12 +100,13 @@ main (int argc, char **argv)
 
   if (parse_command_line (argc, argv)) 
     {
+      msg_ui_init ();
       outp_read_devices ();
-      lex_init (do_read_line);
+      the_lexer = lex_create (do_read_line);
 
       for (;;)
         {
-          int result = cmd_parse (the_dataset, 
+          int result = cmd_parse (the_lexer, the_dataset, 
                                  proc_has_source (the_dataset)
                                   ? CMD_STATE_DATA : CMD_STATE_INITIAL);
           if (result == CMD_EOF || result == CMD_FINISH)
@@ -186,7 +188,7 @@ terminate (bool success)
       random_done ();
       settings_done ();
       fh_done ();
-      lex_done ();
+      lex_destroy (the_lexer);
       getl_uninitialize ();
       readln_uninitialize ();