blob: eb355f0332eeca64ffba9fcd9656e5993fdcd43e [file] [log] [blame]
Mark Sleee9ce01c2007-05-16 02:29:53 +00001// Copyright (c) 2006- Facebook
2// Distributed under the Thrift Software License
3//
4// See accompanying file LICENSE or visit the Thrift site at:
5// http://developers.facebook.com/thrift/
6
Mark Slee31985722006-05-24 21:45:31 +00007#ifndef T_MAIN_H
8#define T_MAIN_H
9
Mark Sleef0712dc2006-10-25 19:03:57 +000010#include <string>
Mark Slee30152872006-11-28 01:24:07 +000011#include "parse/t_const.h"
Mark Slee7ff32452007-02-01 05:26:18 +000012#include "parse/t_field.h"
Mark Sleef0712dc2006-10-25 19:03:57 +000013
Mark Sleef5377b32006-10-10 01:42:59 +000014/**
15 * Defined in the flex library
16 */
Mark Slee31985722006-05-24 21:45:31 +000017
Mark Sleef0712dc2006-10-25 19:03:57 +000018int yylex(void);
19
20int yyparse(void);
Mark Slee31985722006-05-24 21:45:31 +000021
Mark Sleef5377b32006-10-10 01:42:59 +000022/**
23 * Expected to be defined by Flex/Bison
24 */
David Reiss0babe402008-06-10 22:56:12 +000025void yyerror(const char* fmt, ...);
Mark Slee31985722006-05-24 21:45:31 +000026
Mark Sleef5377b32006-10-10 01:42:59 +000027/**
Mark Sleef0712dc2006-10-25 19:03:57 +000028 * Parse debugging output, used to print helpful info
Mark Sleef5377b32006-10-10 01:42:59 +000029 */
David Reiss0babe402008-06-10 22:56:12 +000030void pdebug(const char* fmt, ...);
Mark Sleef0712dc2006-10-25 19:03:57 +000031
32/**
33 * Parser warning
34 */
David Reiss0babe402008-06-10 22:56:12 +000035void pwarning(int level, const char* fmt, ...);
Mark Sleef0712dc2006-10-25 19:03:57 +000036
37/**
38 * Failure!
39 */
Mark Slee30152872006-11-28 01:24:07 +000040void failure(const char* fmt, ...);
41
42/**
43 * Check constant types
44 */
45void validate_const_type(t_const* c);
Mark Sleef0712dc2006-10-25 19:03:57 +000046
47/**
Mark Slee7ff32452007-02-01 05:26:18 +000048 * Check constant types
49 */
50void validate_field_value(t_field* field, t_const_value* cv);
51
52/**
Mark Slee91f2b7b2008-01-31 01:49:16 +000053 * Check members of a throws block
54 */
55bool validate_throws(t_struct* throws);
56
57/**
Mark Sleef0712dc2006-10-25 19:03:57 +000058 * Converts a string filename into a thrift program name
59 */
60std::string program_name(std::string filename);
61
62/**
63 * Gets the directory path of a filename
64 */
65std::string directory_name(std::string filename);
66
67/**
68 * Get the absolute path for an include file
69 */
70std::string include_file(std::string filename);
Mark Sleef5377b32006-10-10 01:42:59 +000071
72/**
David Reisscbd4bac2007-08-14 17:12:33 +000073 * Clears any previously stored doctext string.
74 */
75void clear_doctext();
76
77/**
David Reiss1ac05802007-07-30 22:00:27 +000078 * Cleans up text commonly found in doxygen-like comments
79 */
80char* clean_up_doctext(char* doctext);
81
82/**
Mark Sleef5377b32006-10-10 01:42:59 +000083 * Flex utilities
84 */
85
Mark Slee31985722006-05-24 21:45:31 +000086extern int yylineno;
87extern char yytext[];
88extern FILE* yyin;
89
90#endif