36d79d3afef7a2a25bf7cf7139195ade4f7267dc
[pspp-builds.git] / src / language / lexer / lexer.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #if !lexer_h
21 #define lexer_h 1
22
23 #include <data/variable.h>
24 #include <ctype.h>
25 #include <stdbool.h>
26
27 #include <data/identifier.h>
28
29
30 extern int token;
31 extern double tokval;
32 extern char tokid[LONG_NAME_LEN + 1];
33 extern struct string tokstr;
34
35 #include <stddef.h>
36
37 /* Initialization. */
38 void lex_init (void);
39 void lex_done (void);
40
41 /* Common functions. */
42 void lex_get (void);
43 void lex_error (const char *, ...);
44 void lex_sbc_only_once (const char *);
45 void lex_sbc_missing (const char *);
46 int lex_end_of_command (void);
47
48 /* Token testing functions. */
49 bool lex_is_number (void);
50 double lex_number (void);
51 bool lex_is_integer (void);
52 long lex_integer (void);
53
54 /* Token matching functions. */
55 int lex_match (int);
56 int lex_match_id (const char *);
57 int lex_match_int (int);
58
59 /* Forcible matching functions. */
60 int lex_force_match (int);
61 int lex_force_match_id (const char *);
62 int lex_force_int (void);
63 int lex_force_num (void);
64 int lex_force_id (void);
65 int lex_force_string (void);
66         
67 /* Weird token functions. */
68 int lex_look_ahead (void);
69 void lex_put_back (int);
70 void lex_put_back_id (const char *tokid);
71
72 /* Weird line processing functions. */
73 const char *lex_entire_line (void);
74 const char *lex_rest_of_line (int *end_dot);
75 void lex_discard_line (void);
76 void lex_set_prog (char *p);
77 void lex_discard_rest_of_command (void);
78
79 /* Weird line reading functions. */
80 bool lex_get_line (void);
81
82 /* Token names. */
83 const char *lex_token_name (int);
84 char *lex_token_representation (void);
85
86 /* Really weird functions. */
87 void lex_negative_to_dash (void);
88 void lex_reset_eof (void);
89 void lex_skip_comment (void);
90
91 #endif /* !lexer_h */