David Reiss | ea2cba8 | 2009-03-30 21:35:00 +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 | */ |
Mark Slee | e9ce01c | 2007-05-16 02:29:53 +0000 | [diff] [blame] | 19 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 20 | #ifndef T_MAIN_H |
| 21 | #define T_MAIN_H |
| 22 | |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 23 | #include <string> |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 24 | #include "parse/t_const.h" |
Mark Slee | 7ff3245 | 2007-02-01 05:26:18 +0000 | [diff] [blame] | 25 | #include "parse/t_field.h" |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 26 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 27 | /** |
| 28 | * Defined in the flex library |
| 29 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 30 | |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 31 | int yylex(void); |
| 32 | |
| 33 | int yyparse(void); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 34 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 35 | /** |
| 36 | * Expected to be defined by Flex/Bison |
| 37 | */ |
David Reiss | 0babe40 | 2008-06-10 22:56:12 +0000 | [diff] [blame] | 38 | void yyerror(const char* fmt, ...); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 39 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 40 | /** |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 41 | * Parse debugging output, used to print helpful info |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 42 | */ |
David Reiss | 0babe40 | 2008-06-10 22:56:12 +0000 | [diff] [blame] | 43 | void pdebug(const char* fmt, ...); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * Parser warning |
| 47 | */ |
David Reiss | 0babe40 | 2008-06-10 22:56:12 +0000 | [diff] [blame] | 48 | void pwarning(int level, const char* fmt, ...); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 49 | |
| 50 | /** |
Jens Geyer | 1bd9424 | 2013-04-19 20:15:05 +0200 | [diff] [blame] | 51 | * Print verbose output message |
| 52 | */ |
| 53 | void pverbose(const char* fmt, ...); |
| 54 | |
| 55 | /** |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 56 | * Failure! |
| 57 | */ |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 58 | void failure(const char* fmt, ...); |
| 59 | |
| 60 | /** |
Jens Geyer | 12c09f4 | 2013-08-25 14:16:27 +0200 | [diff] [blame] | 61 | * Check simple identifier names |
| 62 | */ |
| 63 | void validate_simple_identifier(const char* identifier); |
| 64 | |
| 65 | /** |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 66 | * Check constant types |
| 67 | */ |
| 68 | void validate_const_type(t_const* c); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 69 | |
| 70 | /** |
Mark Slee | 7ff3245 | 2007-02-01 05:26:18 +0000 | [diff] [blame] | 71 | * Check constant types |
| 72 | */ |
| 73 | void validate_field_value(t_field* field, t_const_value* cv); |
| 74 | |
| 75 | /** |
Mark Slee | 91f2b7b | 2008-01-31 01:49:16 +0000 | [diff] [blame] | 76 | * Check members of a throws block |
| 77 | */ |
| 78 | bool validate_throws(t_struct* throws); |
| 79 | |
| 80 | /** |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 81 | * Converts a string filename into a thrift program name |
| 82 | */ |
| 83 | std::string program_name(std::string filename); |
| 84 | |
| 85 | /** |
| 86 | * Gets the directory path of a filename |
| 87 | */ |
| 88 | std::string directory_name(std::string filename); |
| 89 | |
| 90 | /** |
| 91 | * Get the absolute path for an include file |
| 92 | */ |
| 93 | std::string include_file(std::string filename); |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 94 | |
| 95 | /** |
David Reiss | cbd4bac | 2007-08-14 17:12:33 +0000 | [diff] [blame] | 96 | * Clears any previously stored doctext string. |
| 97 | */ |
| 98 | void clear_doctext(); |
| 99 | |
| 100 | /** |
David Reiss | 1ac0580 | 2007-07-30 22:00:27 +0000 | [diff] [blame] | 101 | * Cleans up text commonly found in doxygen-like comments |
| 102 | */ |
| 103 | char* clean_up_doctext(char* doctext); |
| 104 | |
| 105 | /** |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 106 | * Flex utilities |
| 107 | */ |
| 108 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 109 | extern int yylineno; |
| 110 | extern char yytext[]; |
| 111 | extern FILE* yyin; |
| 112 | |
| 113 | #endif |