blob: cd4b032a32a3d17fde1a5e17712962e937425f50 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
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 Sleee9ce01c2007-05-16 02:29:53 +000019
Mark Slee31985722006-05-24 21:45:31 +000020#ifndef T_MAIN_H
21#define T_MAIN_H
22
Mark Sleef0712dc2006-10-25 19:03:57 +000023#include <string>
Konrad Grochowski13699f82015-05-04 11:21:22 +020024#include <cstdio>
25
Jens Geyer813749d2014-01-31 23:42:57 +010026#include "logging.h"
Konrad Grochowski13699f82015-05-04 11:21:22 +020027
Mark Slee30152872006-11-28 01:24:07 +000028#include "parse/t_const.h"
Mark Slee7ff32452007-02-01 05:26:18 +000029#include "parse/t_field.h"
Mark Sleef0712dc2006-10-25 19:03:57 +000030
Mark Sleef5377b32006-10-10 01:42:59 +000031/**
32 * Defined in the flex library
33 */
Mark Slee31985722006-05-24 21:45:31 +000034
Konrad Grochowski16a23a62014-11-13 15:33:38 +010035extern "C" { int yylex(void); }
Mark Sleef0712dc2006-10-25 19:03:57 +000036
37int yyparse(void);
Mark Slee31985722006-05-24 21:45:31 +000038
Mark Sleef5377b32006-10-10 01:42:59 +000039/**
40 * Expected to be defined by Flex/Bison
41 */
David Reiss0babe402008-06-10 22:56:12 +000042void yyerror(const char* fmt, ...);
Mark Slee31985722006-05-24 21:45:31 +000043
Mark Sleef5377b32006-10-10 01:42:59 +000044/**
Jens Geyer12c09f42013-08-25 14:16:27 +020045 * Check simple identifier names
46 */
47void validate_simple_identifier(const char* identifier);
48
49/**
Mark Slee30152872006-11-28 01:24:07 +000050 * Check constant types
51 */
52void validate_const_type(t_const* c);
Mark Sleef0712dc2006-10-25 19:03:57 +000053
54/**
Mark Slee7ff32452007-02-01 05:26:18 +000055 * Check constant types
56 */
57void validate_field_value(t_field* field, t_const_value* cv);
58
59/**
Mark Slee91f2b7b2008-01-31 01:49:16 +000060 * Check members of a throws block
61 */
62bool validate_throws(t_struct* throws);
63
64/**
Mark Sleef0712dc2006-10-25 19:03:57 +000065 * Converts a string filename into a thrift program name
66 */
67std::string program_name(std::string filename);
68
69/**
70 * Gets the directory path of a filename
71 */
72std::string directory_name(std::string filename);
73
74/**
75 * Get the absolute path for an include file
76 */
77std::string include_file(std::string filename);
Mark Sleef5377b32006-10-10 01:42:59 +000078
79/**
David Reisscbd4bac2007-08-14 17:12:33 +000080 * Clears any previously stored doctext string.
81 */
82void clear_doctext();
83
84/**
David Reiss1ac05802007-07-30 22:00:27 +000085 * Cleans up text commonly found in doxygen-like comments
86 */
87char* clean_up_doctext(char* doctext);
88
89/**
Jens Geyere8379b52014-01-25 00:59:45 +010090 * We are sure the program doctext candidate is really the program doctext.
91 */
92void declare_valid_program_doctext();
93
Jens Geyer6fe77e82014-03-16 16:48:53 +020094/**
95 * Emits a warning on list<byte>, binary type is typically a much better choice.
96 */
97void check_for_list_of_bytes(t_type* list_elem_type);
Jens Geyere8379b52014-01-25 00:59:45 +010098
99/**
Mark Sleef5377b32006-10-10 01:42:59 +0000100 * Flex utilities
101 */
102
Konrad Grochowski16a23a62014-11-13 15:33:38 +0100103extern int yylineno;
104extern char yytext[];
Konrad Grochowski13699f82015-05-04 11:21:22 +0200105extern std::FILE* yyin;
Mark Slee31985722006-05-24 21:45:31 +0000106
107#endif