blob: cb6d27a6b903480d4bd05d003fc3c1e278061974 [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>
Mark Slee30152872006-11-28 01:24:07 +000024#include "parse/t_const.h"
Mark Slee7ff32452007-02-01 05:26:18 +000025#include "parse/t_field.h"
Mark Sleef0712dc2006-10-25 19:03:57 +000026
Mark Sleef5377b32006-10-10 01:42:59 +000027/**
28 * Defined in the flex library
29 */
Mark Slee31985722006-05-24 21:45:31 +000030
Mark Sleef0712dc2006-10-25 19:03:57 +000031int yylex(void);
32
33int yyparse(void);
Mark Slee31985722006-05-24 21:45:31 +000034
Mark Sleef5377b32006-10-10 01:42:59 +000035/**
36 * Expected to be defined by Flex/Bison
37 */
David Reiss0babe402008-06-10 22:56:12 +000038void yyerror(const char* fmt, ...);
Mark Slee31985722006-05-24 21:45:31 +000039
Mark Sleef5377b32006-10-10 01:42:59 +000040/**
Mark Sleef0712dc2006-10-25 19:03:57 +000041 * Parse debugging output, used to print helpful info
Mark Sleef5377b32006-10-10 01:42:59 +000042 */
David Reiss0babe402008-06-10 22:56:12 +000043void pdebug(const char* fmt, ...);
Mark Sleef0712dc2006-10-25 19:03:57 +000044
45/**
46 * Parser warning
47 */
David Reiss0babe402008-06-10 22:56:12 +000048void pwarning(int level, const char* fmt, ...);
Mark Sleef0712dc2006-10-25 19:03:57 +000049
50/**
Jens Geyer1bd94242013-04-19 20:15:05 +020051 * Print verbose output message
52 */
53void pverbose(const char* fmt, ...);
54
55/**
Mark Sleef0712dc2006-10-25 19:03:57 +000056 * Failure!
57 */
Mark Slee30152872006-11-28 01:24:07 +000058void failure(const char* fmt, ...);
59
60/**
61 * Check constant types
62 */
63void validate_const_type(t_const* c);
Mark Sleef0712dc2006-10-25 19:03:57 +000064
65/**
Mark Slee7ff32452007-02-01 05:26:18 +000066 * Check constant types
67 */
68void validate_field_value(t_field* field, t_const_value* cv);
69
70/**
Mark Slee91f2b7b2008-01-31 01:49:16 +000071 * Check members of a throws block
72 */
73bool validate_throws(t_struct* throws);
74
75/**
Mark Sleef0712dc2006-10-25 19:03:57 +000076 * Converts a string filename into a thrift program name
77 */
78std::string program_name(std::string filename);
79
80/**
81 * Gets the directory path of a filename
82 */
83std::string directory_name(std::string filename);
84
85/**
86 * Get the absolute path for an include file
87 */
88std::string include_file(std::string filename);
Mark Sleef5377b32006-10-10 01:42:59 +000089
90/**
David Reisscbd4bac2007-08-14 17:12:33 +000091 * Clears any previously stored doctext string.
92 */
93void clear_doctext();
94
95/**
David Reiss1ac05802007-07-30 22:00:27 +000096 * Cleans up text commonly found in doxygen-like comments
97 */
98char* clean_up_doctext(char* doctext);
99
100/**
Mark Sleef5377b32006-10-10 01:42:59 +0000101 * Flex utilities
102 */
103
Mark Slee31985722006-05-24 21:45:31 +0000104extern int yylineno;
105extern char yytext[];
106extern FILE* yyin;
107
108#endif