blob: 9b7d82d7d30b4b21a5f7debc179d9bf08fa94e88 [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/**
51 * Failure!
52 */
Mark Slee30152872006-11-28 01:24:07 +000053void failure(const char* fmt, ...);
54
55/**
56 * Check constant types
57 */
58void validate_const_type(t_const* c);
Mark Sleef0712dc2006-10-25 19:03:57 +000059
60/**
Mark Slee7ff32452007-02-01 05:26:18 +000061 * Check constant types
62 */
63void validate_field_value(t_field* field, t_const_value* cv);
64
65/**
Mark Slee91f2b7b2008-01-31 01:49:16 +000066 * Check members of a throws block
67 */
68bool validate_throws(t_struct* throws);
69
70/**
Mark Sleef0712dc2006-10-25 19:03:57 +000071 * Converts a string filename into a thrift program name
72 */
73std::string program_name(std::string filename);
74
75/**
76 * Gets the directory path of a filename
77 */
78std::string directory_name(std::string filename);
79
80/**
81 * Get the absolute path for an include file
82 */
83std::string include_file(std::string filename);
Mark Sleef5377b32006-10-10 01:42:59 +000084
85/**
David Reisscbd4bac2007-08-14 17:12:33 +000086 * Clears any previously stored doctext string.
87 */
88void clear_doctext();
89
90/**
David Reiss1ac05802007-07-30 22:00:27 +000091 * Cleans up text commonly found in doxygen-like comments
92 */
93char* clean_up_doctext(char* doctext);
94
95/**
Mark Sleef5377b32006-10-10 01:42:59 +000096 * Flex utilities
97 */
98
Mark Slee31985722006-05-24 21:45:31 +000099extern int yylineno;
100extern char yytext[];
101extern FILE* yyin;
102
103#endif