Update all #include directives to the currently preferred style.
[pspp-builds.git] / src / language / lexer / lexer.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000, 2010, 2011 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
24 #include "data/identifier.h"
25 #include "data/variable.h"
26 #include "libpspp/getl.h"
27
28 struct lexer;
29
30 /* Initialization. */
31 struct lexer * lex_create (struct source_stream *);
32 void lex_destroy (struct lexer *);
33
34 /* State accessors */
35 struct source_stream * lex_get_source_stream (const struct lexer *);
36 enum syntax_mode lex_current_syntax_mode (const struct lexer *);
37 enum error_mode lex_current_error_mode (const struct lexer *);
38
39 /* Common functions. */
40 void lex_get (struct lexer *);
41 void lex_error (struct lexer *, const char *, ...);
42 void lex_sbc_only_once (const char *);
43 void lex_sbc_missing (struct lexer *, const char *);
44 int lex_end_of_command (struct lexer *);
45
46 /* Token testing functions. */
47 bool lex_is_number (struct lexer *);
48 double lex_number (struct lexer *);
49 bool lex_is_integer (struct lexer *);
50 long lex_integer (struct lexer *);
51 bool lex_is_string (struct lexer *);
52
53
54 /* Token matching functions. */
55 bool lex_match (struct lexer *, enum token_type);
56 bool lex_match_id (struct lexer *, const char *);
57 bool lex_match_id_n (struct lexer *, const char *, size_t n);
58 bool lex_match_int (struct lexer *, int);
59 bool lex_match_hyphenated_word (struct lexer *lexer, const char *s);
60
61
62 /* Forcible matching functions. */
63 bool lex_force_match (struct lexer *, enum token_type);
64 bool lex_force_match_id (struct lexer *, const char *);
65 bool lex_force_int (struct lexer *);
66 bool lex_force_num (struct lexer *);
67 bool lex_force_id (struct lexer *);
68 bool lex_force_string (struct lexer *);
69
70 /* Weird token functions. */
71 enum token_type lex_look_ahead (struct lexer *);
72 void lex_put_back (struct lexer *, enum token_type);
73
74 /* Weird line processing functions. */
75 const char *lex_entire_line (const struct lexer *);
76 const struct string *lex_entire_line_ds (const struct lexer *);
77 const char *lex_rest_of_line (const struct lexer *);
78 bool lex_end_dot (const struct lexer *);
79 void lex_preprocess_line (struct string *, enum syntax_mode,
80                           bool *line_starts_command,
81                           bool *line_ends_command);
82 void lex_discard_line (struct lexer *);
83 void lex_discard_rest_of_command (struct lexer *);
84
85 /* Weird line reading functions. */
86 bool lex_get_line (struct lexer *);
87 bool lex_get_line_raw (struct lexer *);
88
89 /* Token names. */
90 const char *lex_token_name (enum token_type);
91 char *lex_token_representation (struct lexer *);
92
93 /* Token accessors */
94 enum token_type lex_token (const struct lexer *);
95 double lex_tokval (const struct lexer *);
96 const char *lex_tokcstr (const struct lexer *);
97 struct substring lex_tokss (const struct lexer *);
98
99 /* Really weird functions. */
100 void lex_skip_comment (struct lexer *);
101
102 #endif /* !lexer_h */