nis-util  1.0.D108
lib/colon.h
Go to the documentation of this file.
00001 //
00002 // nis-util - NIS Administration Utilities
00003 // Copyright (C) 2001, 2008, 2009, 2011, 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or (at
00008 // your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef LIB_COLON_H
00020 #define LIB_COLON_H
00021 
00022 #include <lib/config.h>
00023 #include <vector>
00024 
00025 #include <lib/gcc-attr.h>
00026 #include <lib/input.h>
00027 #include <lib/rcstring.h>
00028 #include <lib/source_location.h>
00029 
00034 class colon
00035 {
00036 public:
00040     virtual ~colon();
00041 
00045     colon(const rcstring &filename);
00046 
00047 private:
00052     void open(void);
00053 
00058     void lex(void);
00059 
00064     source_location get_source_location(void) const;
00065 
00066 protected:
00072     void close(void);
00073 
00077     typedef std::vector<rcstring> line_t;
00078 
00088     bool read_one_line(line_t &result);
00089 
00101     bool read_one_line(source_location &result_locn, line_t &result);
00102 
00114     void error(const source_location &locn, const char *fmt, ...)
00115                                                          ATTRIBUTE_PRINTF(3, 4);
00116 
00129     void pedantic_error(const source_location &locn, const char *fmt, ...)
00130                                                          ATTRIBUTE_PRINTF(3, 4);
00131 
00144     void warning(const source_location &locn, const char *fmt, ...)
00145                                                          ATTRIBUTE_PRINTF(3, 4);
00146 
00147 public:
00152     void discard_blank_lines(void);
00153 
00159     void discard_comments(void);
00160 
00166     void explain_sequence_errors(void);
00167 
00168 private:
00182     void verror(const source_location &locn, const char *fmt, va_list ap)
00183                                                          ATTRIBUTE_PRINTF(3, 0);
00184 
00199     void vwarning(const source_location &locn, const char *fmt, va_list ap)
00200                                                          ATTRIBUTE_PRINTF(3, 0);
00201 
00216     void vpedantic_error(const source_location &locn, const char *fmt,
00217         va_list ap)                                      ATTRIBUTE_PRINTF(3, 0);
00218 
00219     enum token_ty
00220     {
00221         token_eof,
00222         token_eoln,
00223         token_colon,
00224         token_string
00225     };
00226 
00231     rcstring filename;
00232 
00237     input::pointer ip;
00238 
00242     bool non_printing_whine;
00243 
00247     token_ty token;
00248 
00253     rcstring token_value;
00254 
00258     int error_count;
00259 
00263     bool discard_comments_flag;
00264 
00268     bool discard_blank_lines_flag;
00269 
00274     source_location token_locn;
00275 
00280     bool explained_sequence_errors;
00281 
00285     colon();
00286 
00290     colon(const colon &);
00291 
00295     colon &operator=(const colon &);
00296 };
00297 
00298 // vim: set ts=8 sw=4 et :
00299 #endif // LIB_COLON_H