]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/lex.h
Initial revision
[bacula/bacula] / bacula / src / lib / lex.h
1 /*
2  *   lex.h  
3  *
4  *    Lexial scanning of configuration files, used by parsers.
5  *
6  *   Kern Sibbald, MM  
7  *
8  */
9 /*
10    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License as
14    published by the Free Software Foundation; either version 2 of
15    the License, or (at your option) any later version.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20    General Public License for more details.
21
22    You should have received a copy of the GNU General Public
23    License along with this program; if not, write to the Free
24    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25    MA 02111-1307, USA.
26
27  */
28
29 #ifndef _LEX_H
30 #define _LEX_H
31
32 /* Lex get_char() return values */
33 #define L_EOF                         (-1)
34 #define L_EOL                         (-2)
35
36 /* Internal tokens */
37 #define T_NONE                        100                              
38
39 /* Tokens returned by get_token() */
40 #define T_EOF                         101
41 #define T_NUMBER                      102
42 #define T_IPADDR                      103
43 #define T_IDENTIFIER                  104
44 #define T_STRING                      105
45 #define T_QUOTED_STRING               106
46 #define T_BOB                         108  /* begin block */
47 #define T_EOB                         109  /* end of block */
48 #define T_EQUALS                      110
49 #define T_COMMA                       111
50 #define T_EOL                         112
51 #define T_SEMI                        113
52 #define T_ERROR                       200
53
54 /* Lexical state */
55 enum lex_state {
56    lex_none,
57    lex_comment,
58    lex_number,
59    lex_ip_addr,
60    lex_identifier,
61    lex_string,
62    lex_quoted_string,
63    lex_include
64 };
65
66 /* Lex scan options */
67 #define LOPT_NO_IDENT            0x1  /* No Identifiers -- use string */
68
69 /* Lexical context */
70 typedef struct s_lex_context {
71    int options;                       /* scan options */
72    char *fname;                       /* filename */
73    FILE *fd;                          /* file descriptor */
74    char line[MAXSTRING];              /* input line */
75    char str[MAXSTRING];               /* string being scanned */
76    int str_len;                       /* length of string */
77    int line_no;                       /* file line number */
78    int col_no;                        /* char position on line */
79    enum lex_state state;              /* lex_state variable */
80    int ch;                            /* last char/L_VAL returned by get_char */
81    int token;
82    struct s_lex_context *next;        /* pointer to next lexical context */
83 } LEX;
84
85 #endif /* _LEX_H */