-/* PSPP - computes sample statistics.
+/* PSPP - a program for statistical analysis.
Copyright (C) 1997-9, 2000, 2006 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 the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <config.h>
#include <libpspp/str.h>
#include <libpspp/ll.h>
#include <libpspp/version.h>
-#include <libpspp/alloc.h>
+
+#include "xalloc.h"
struct getl_source
{
struct ll ll; /* Element in the sources list */
struct getl_interface *interface;
+ enum syntax_mode syntax_mode;
+ enum error_mode error_mode;
};
struct source_stream
return ll_data (ll, struct getl_source, ll );
}
+enum syntax_mode
+source_stream_current_syntax_mode (const struct source_stream *ss)
+{
+ struct getl_source *cs = current_source (ss);
+
+ return cs->syntax_mode;
+}
+
+
+
+enum error_mode
+source_stream_current_error_mode (const struct source_stream *ss)
+{
+ struct getl_source *cs = current_source (ss);
+
+ return cs->error_mode;
+}
+
+
+
/* Initialize getl. */
struct source_stream *
create_source_stream (const char *initial_include_path)
/* Appends source S to the list of source files. */
void
-getl_append_source (struct source_stream *ss, struct getl_interface *i)
+getl_append_source (struct source_stream *ss,
+ struct getl_interface *i,
+ enum syntax_mode syntax_mode,
+ enum error_mode err_mode)
{
struct getl_source *s = xzalloc (sizeof ( struct getl_source ));
s->interface = i ;
+ s->syntax_mode = syntax_mode;
+ s->error_mode = err_mode;
- ll_push_head (&ss->sources, &s->ll);
+ ll_push_tail (&ss->sources, &s->ll);
}
/* Nests source S within the current source file. */
void
-getl_include_source (struct source_stream *ss, struct getl_interface *i)
+getl_include_source (struct source_stream *ss,
+ struct getl_interface *i,
+ enum syntax_mode syntax_mode,
+ enum error_mode err_mode)
{
struct getl_source *current = current_source (ss);
struct getl_source *s = xzalloc (sizeof ( struct getl_source ));
s->included_from = current ;
s->includes = NULL;
+ s->syntax_mode = syntax_mode;
+ s->error_mode = err_mode;
current->includes = s;
ll_push_head (&ss->sources, &s->ll);
/* Reads a single line into LINE.
Returns true when a line has been read, false at end of input.
- On success, sets *SYNTAX to the style of the syntax read. */
+*/
bool
-getl_read_line (struct source_stream *ss, struct string *line,
- enum getl_syntax *syntax)
+getl_read_line (struct source_stream *ss, struct string *line)
{
+ assert (ss != NULL);
while (!ll_is_empty (&ss->sources))
{
struct getl_source *s = current_source (ss);
ds_clear (line);
- if (s->interface->read (s->interface, line, syntax))
+ if (s->interface->read (s->interface, line))
{
while (s)
{
if (s->interface->filter)
- s->interface->filter (s->interface, line, *syntax);
+ s->interface->filter (s->interface, line);
s = s->included_from;
}