| 1 |
/* This may look like C code, but it is really -*- C++ -*- */ |
| 2 |
|
| 3 |
/* Input routines. |
| 4 |
|
| 5 |
Copyright (C) 1989-1998, 2002-2003, 2025 Free Software Foundation, Inc. |
| 6 |
Written by Douglas C. Schmidt <[email protected]> |
| 7 |
and Bruno Haible <[email protected]>. |
| 8 |
|
| 9 |
This file is part of GNU GPERF. |
| 10 |
|
| 11 |
This program is free software: you can redistribute it and/or modify |
| 12 |
it under the terms of the GNU General Public License as published by |
| 13 |
the Free Software Foundation; either version 3 of the License, or |
| 14 |
(at your option) any later version. |
| 15 |
|
| 16 |
This program is distributed in the hope that it will be useful, |
| 17 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
GNU General Public License for more details. |
| 20 |
|
| 21 |
You should have received a copy of the GNU General Public License |
| 22 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 23 |
|
| 24 |
#ifndef input_h |
| 25 |
#define input_h 1 |
| 26 |
|
| 27 |
#include <stdio.h> |
| 28 |
#include "keyword-list.h" |
| 29 |
|
| 30 |
template <class KT> |
| 31 |
class Input |
| 32 |
{ |
| 33 |
public: |
| 34 |
Input (FILE *stream, Keyword_Factory<KT> *keyword_factory); |
| 35 |
~Input (); |
| 36 |
void read_input (); |
| 37 |
private: |
| 38 |
/* Input stream. */ |
| 39 |
FILE * _stream; |
| 40 |
/* Creates the keywords. */ |
| 41 |
Keyword_Factory<KT> * const _factory; |
| 42 |
public: |
| 43 |
/* Memory block containing the entire input. */ |
| 44 |
char * _input; |
| 45 |
char * _input_end; |
| 46 |
/* The C code from the declarations section. */ |
| 47 |
const char * _verbatim_declarations; |
| 48 |
const char * _verbatim_declarations_end; |
| 49 |
unsigned int _verbatim_declarations_lineno; |
| 50 |
/* The C code from the end of the file. */ |
| 51 |
const char * _verbatim_code; |
| 52 |
const char * _verbatim_code_end; |
| 53 |
unsigned int _verbatim_code_lineno; |
| 54 |
/* Declaration of struct type for a keyword and its attributes. */ |
| 55 |
const char * _struct_decl; |
| 56 |
unsigned int _struct_decl_lineno; |
| 57 |
/* Return type of the lookup function. */ |
| 58 |
const char * _return_type; |
| 59 |
/* Shorthand for user-defined struct tag type. */ |
| 60 |
const char * _struct_tag; |
| 61 |
/* List of all keywords. */ |
| 62 |
Keyword_List<KT> * _head; |
| 63 |
/* Whether the keyword chars would have different values in a different |
| 64 |
character set. */ |
| 65 |
bool _charset_dependent; |
| 66 |
}; |
| 67 |
|
| 68 |
#endif |