X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fgetl.h;h=3142d3870622ad0af62aa7ab6c8724a43cea70ae;hb=9683d7528884fcb3c60705812de9f96889536388;hp=34c9b912e6f467e5bc16b1f6b750312612ab9907;hpb=b8b67a1e1f709640ccdb3422a591b938edb0ceea;p=pspp-builds.git diff --git a/src/libpspp/getl.h b/src/libpspp/getl.h index 34c9b912..3142d387 100644 --- a/src/libpspp/getl.h +++ b/src/libpspp/getl.h @@ -1,6 +1,5 @@ /* PSPP - computes sample statistics. Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc. - Written by Ben Pfaff . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -23,26 +22,46 @@ #include #include -struct string; +struct string; struct getl_source; +/* Syntax rules that apply to a given source line. */ +enum getl_syntax + { + /* Each line that begins in column 1 starts a new command. A + `+' or `-' in column 1 is ignored to allow visual + indentation of new commands. Continuation lines must be + indented from the left margin. A period at the end of a + line does end a command, but it is optional. */ + GETL_BATCH, + + /* Each command must end in a period or in a blank line. */ + GETL_INTERACTIVE + }; -/* An abstract base class for objects which act as line buffers for the +/* An abstract base class for objects which act as line buffers for the PSPP. Ie anything which might contain content for the lexer */ -struct getl_interface +struct getl_interface { - /* Returns true, if the interface is interactive */ - bool (*interactive) (const struct getl_interface *); + /* Returns true if the interface is interactive, that is, if + it prompts a human user. This property is independent of + the syntax mode returned by the read member function. */ + bool (*interactive) (const struct getl_interface *); - /* Read a line from the interface */ - bool (*read) (struct getl_interface *, struct string *); + /* Read a line the intended syntax mode from the interface. + Returns true if succesful, false on failure or at end of + input. */ + bool (*read) (struct getl_interface *, + struct string *, enum getl_syntax *); /* Close and destroy the interface */ void (*close) (struct getl_interface *); - /* Filter for current and all included sources. May be NULL */ - void (*filter) (struct getl_interface *, struct string *line); + /* Filter for current and all included sources, which may + modify the line. Usually null. */ + void (*filter) (struct getl_interface *, + struct string *line, enum getl_syntax); /* Returns the name of the source */ const char * (*name) (const struct getl_interface *); @@ -51,24 +70,25 @@ struct getl_interface int (*location) (const struct getl_interface *); }; -void getl_initialize (void); -void getl_uninitialize (void); +struct source_stream; -void getl_clear_include_path (void); -void getl_add_include_dir (const char *); -const char * getl_include_path (void); +struct source_stream * create_source_stream (const char *); +void destroy_source_stream (struct source_stream *); -void getl_abort_noninteractive (void); -bool getl_is_interactive (void); +void getl_clear_include_path (struct source_stream *); +void getl_add_include_dir (struct source_stream *, const char *); +const char * getl_include_path (const struct source_stream *); -bool getl_read_line (bool *interactive); +void getl_abort_noninteractive (struct source_stream *); +bool getl_is_interactive (const struct source_stream *); -bool do_read_line (struct string *line, bool *interactive); +bool getl_read_line (struct source_stream *, struct string *, + enum getl_syntax *); -void getl_append_source (struct getl_interface *s) ; -void getl_include_source (struct getl_interface *s) ; +void getl_append_source (struct source_stream *, struct getl_interface *s) ; +void getl_include_source (struct source_stream *, struct getl_interface *s) ; -const char * getl_source_name (void); -int getl_source_location (void); +const char * getl_source_name (const struct source_stream *); +int getl_source_location (const struct source_stream *); #endif /* line-buffer.h */