Change license from GPLv2+ to GPLv3+.
[pspp-builds.git] / src / language / lexer / lexer.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #if !lexer_h
18 #define lexer_h 1
19
20 #include <ctype.h>
21 #include <stdbool.h>
22 #include <stddef.h>
23 #include <data/identifier.h>
24 #include <data/variable.h>
25 #include <libpspp/getl.h>
26
27 struct lexer;
28
29 /* Initialization. */
30 struct lexer * lex_create (struct source_stream *);
31 void lex_destroy (struct lexer *);
32
33 struct source_stream * lex_get_source_stream (const struct lexer *);
34
35
36 /* Common functions. */
37 void lex_get (struct lexer *);
38 void lex_error (struct lexer *, const char *, ...);
39 void lex_sbc_only_once (const char *);
40 void lex_sbc_missing (struct lexer *, const char *);
41 int lex_end_of_command (struct lexer *);
42
43 /* Token testing functions. */
44 bool lex_is_number (struct lexer *);
45 double lex_number (struct lexer *);
46 bool lex_is_integer (struct lexer *);
47 long lex_integer (struct lexer *);
48 bool lex_is_string (struct lexer *);
49
50
51 /* Token matching functions. */
52 bool lex_match (struct lexer *, int);
53 bool lex_match_id (struct lexer *, const char *);
54 bool lex_match_int (struct lexer *, int);
55
56 /* Forcible matching functions. */
57 bool lex_force_match (struct lexer *, int);
58 bool lex_force_match_id (struct lexer *, const char *);
59 bool lex_force_int (struct lexer *);
60 bool lex_force_num (struct lexer *);
61 bool lex_force_id (struct lexer *);
62 bool lex_force_string (struct lexer *);
63
64 /* Weird token functions. */
65 int lex_look_ahead (struct lexer *);
66 void lex_put_back (struct lexer *, int);
67 void lex_put_back_id (struct lexer *, const char *tokid);
68
69 /* Weird line processing functions. */
70 const char *lex_entire_line (const struct lexer *);
71 const struct string *lex_entire_line_ds (const struct lexer *);
72 const char *lex_rest_of_line (const struct lexer *);
73 bool lex_end_dot (const struct lexer *);
74 void lex_preprocess_line (struct string *, enum getl_syntax,
75                           bool *line_starts_command,
76                           bool *line_ends_command);
77 void lex_discard_line (struct lexer *);
78 void lex_discard_rest_of_command (struct lexer *);
79
80 /* Weird line reading functions. */
81 bool lex_get_line (struct lexer *);
82 bool lex_get_line_raw (struct lexer *, enum getl_syntax *);
83
84 /* Token names. */
85 const char *lex_token_name (int);
86 char *lex_token_representation (struct lexer *);
87
88 /* Token accessors */
89 int lex_token (const struct lexer *);
90 double lex_tokval (const struct lexer *);
91 const char *lex_tokid (const struct lexer *);
92 const struct string *lex_tokstr (const struct lexer *);
93
94 /* Really weird functions. */
95 void lex_negative_to_dash (struct lexer *);
96 void lex_skip_comment (struct lexer *);
97
98 #endif /* !lexer_h */