]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /* |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | ||
20 | #ifndef T_MAIN_H | |
21 | #define T_MAIN_H | |
22 | ||
23 | #include <string> | |
24 | #include <cstdio> | |
25 | ||
26 | #include "thrift/logging.h" | |
27 | ||
28 | #include "thrift/parse/t_const.h" | |
29 | #include "thrift/parse/t_field.h" | |
30 | ||
31 | /** | |
32 | * Defined in the flex library | |
33 | */ | |
34 | ||
35 | extern "C" { int yylex(void); } | |
36 | ||
37 | int yyparse(void); | |
38 | ||
39 | /** | |
40 | * Expected to be defined by Flex/Bison | |
41 | */ | |
42 | void yyerror(const char* fmt, ...); | |
43 | ||
44 | /** | |
45 | * Check simple identifier names | |
46 | */ | |
47 | void validate_simple_identifier(const char* identifier); | |
48 | ||
49 | /** | |
50 | * Check constant types | |
51 | */ | |
52 | void validate_const_type(t_const* c); | |
53 | ||
54 | /** | |
55 | * Check constant types | |
56 | */ | |
57 | void validate_field_value(t_field* field, t_const_value* cv); | |
58 | ||
59 | /** | |
60 | * Check members of a throws block | |
61 | */ | |
62 | bool validate_throws(t_struct* throws); | |
63 | ||
64 | /** | |
65 | * Converts a string filename into a thrift program name | |
66 | */ | |
67 | std::string program_name(std::string filename); | |
68 | ||
69 | /** | |
70 | * Gets the directory path of a filename | |
71 | */ | |
72 | std::string directory_name(std::string filename); | |
73 | ||
74 | /** | |
75 | * Get the absolute path for an include file | |
76 | */ | |
77 | std::string include_file(std::string filename); | |
78 | ||
79 | /** | |
80 | * Clears any previously stored doctext string. | |
81 | */ | |
82 | void clear_doctext(); | |
83 | ||
84 | /** | |
85 | * Cleans up text commonly found in doxygen-like comments | |
86 | */ | |
87 | char* clean_up_doctext(char* doctext); | |
88 | ||
89 | /** | |
90 | * We are sure the program doctext candidate is really the program doctext. | |
91 | */ | |
92 | void declare_valid_program_doctext(); | |
93 | ||
94 | /** | |
95 | * Emits a warning on list<byte>, binary type is typically a much better choice. | |
96 | */ | |
97 | void check_for_list_of_bytes(t_type* list_elem_type); | |
98 | ||
99 | /** | |
100 | * Emits a one-time warning on byte type, promoting the new i8 type instead | |
101 | */ | |
102 | void emit_byte_type_warning(); | |
103 | ||
104 | /** | |
105 | * Prints deprecation notice for old NS declarations that are no longer supported | |
106 | * If new_form is NULL, old_form is assumed to be a language identifier, such as "cpp" | |
107 | * If new_form is not NULL, both arguments are used exactly as given | |
108 | */ | |
109 | void error_unsupported_namespace_decl(const char* old_form, const char* new_form = nullptr); | |
110 | ||
111 | /** | |
112 | * Flex utilities | |
113 | */ | |
114 | ||
115 | extern int yylineno; | |
116 | extern char yytext[]; | |
117 | extern std::FILE* yyin; | |
118 | ||
119 | #endif |