Gavin McDonald | 0b75e1a | 2010-10-28 02:12:01 +0000 | [diff] [blame] | 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 "parse/t_const.h" |
| 25 | #include "parse/t_field.h" |
| 26 | |
| 27 | /** |
| 28 | * Defined in the flex library |
| 29 | */ |
| 30 | |
| 31 | int yylex(void); |
| 32 | |
| 33 | int yyparse(void); |
| 34 | |
| 35 | /** |
| 36 | * Expected to be defined by Flex/Bison |
| 37 | */ |
| 38 | void yyerror(const char* fmt, ...); |
| 39 | |
| 40 | /** |
| 41 | * Parse debugging output, used to print helpful info |
| 42 | */ |
| 43 | void pdebug(const char* fmt, ...); |
| 44 | |
| 45 | /** |
| 46 | * Parser warning |
| 47 | */ |
| 48 | void pwarning(int level, const char* fmt, ...); |
| 49 | |
| 50 | /** |
| 51 | * Failure! |
| 52 | */ |
| 53 | void failure(const char* fmt, ...); |
| 54 | |
| 55 | /** |
| 56 | * Check constant types |
| 57 | */ |
| 58 | void validate_const_type(t_const* c); |
| 59 | |
| 60 | /** |
| 61 | * Check constant types |
| 62 | */ |
| 63 | void validate_field_value(t_field* field, t_const_value* cv); |
| 64 | |
| 65 | /** |
| 66 | * Check members of a throws block |
| 67 | */ |
| 68 | bool validate_throws(t_struct* throws); |
| 69 | |
| 70 | /** |
| 71 | * Converts a string filename into a thrift program name |
| 72 | */ |
| 73 | std::string program_name(std::string filename); |
| 74 | |
| 75 | /** |
| 76 | * Gets the directory path of a filename |
| 77 | */ |
| 78 | std::string directory_name(std::string filename); |
| 79 | |
| 80 | /** |
| 81 | * Get the absolute path for an include file |
| 82 | */ |
| 83 | std::string include_file(std::string filename); |
| 84 | |
| 85 | /** |
| 86 | * Clears any previously stored doctext string. |
| 87 | */ |
| 88 | void clear_doctext(); |
| 89 | |
| 90 | /** |
| 91 | * Cleans up text commonly found in doxygen-like comments |
| 92 | */ |
| 93 | char* clean_up_doctext(char* doctext); |
| 94 | |
| 95 | /** |
| 96 | * Flex utilities |
| 97 | */ |
| 98 | |
| 99 | extern int yylineno; |
| 100 | extern char yytext[]; |
| 101 | extern FILE* yyin; |
| 102 | |
| 103 | #endif |