OpenSDN source code
|
#include <cassert>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <string>
#include <algorithm>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <limits.h>
#include "globals.h"
#include "main.h"
#include "parse/t_program.h"
#include "parse/t_scope.h"
#include "generate/t_generator.h"
#include "version.h"
Go to the source code of this file.
Functions | |
char * | saferealpath (const char *path, char *resolved_path) |
void | yyerror (const char *fmt,...) |
void | pdebug (const char *fmt,...) |
void | pverbose (const char *fmt,...) |
void | pwarning (int level, const char *fmt,...) |
void | failure (const char *fmt,...) |
string | program_name (string filename) |
string | directory_name (string filename) |
string | include_file (string filename) |
void | clear_doctext () |
void | reset_program_doctext_info () |
void | declare_valid_program_doctext () |
char * | clean_up_doctext (char *doctext) |
void | dump_docstrings (t_program *program) |
void | generate_all_fingerprints (t_program *program) |
void | version () |
void | usage () |
void | validate_const_rec (std::string name, t_type *type, t_const_value *value) |
void | validate_const_type (t_const *c) |
void | validate_field_value (t_field *field, t_const_value *cv) |
bool | validate_throws (t_struct *throws) |
void | parse (t_program *program, t_program *parent_program) |
void | generate (t_program *program, const vector< string > &generator_strings) |
char* clean_up_doctext | ( | char * | doctext | ) |
Cleans up text commonly found in doxygen-like comments
Warning: if you mix tabs and spaces in a non-uniform way, you will get what you deserve.
Definition at line 437 of file src/contrail-common/sandesh/compiler/main.cc.
void clear_doctext | ( | ) |
Clears any previously stored doctext string. Also prints a warning if we are discarding information.
Definition at line 397 of file src/contrail-common/sandesh/compiler/main.cc.
void declare_valid_program_doctext | ( | ) |
We are sure the program doctext candidate is really the program doctext.
Definition at line 421 of file src/contrail-common/sandesh/compiler/main.cc.
string directory_name | ( | string | filename | ) |
Gets the directory path of a filename
Definition at line 337 of file src/contrail-common/sandesh/compiler/main.cc.
void dump_docstrings | ( | t_program * | program | ) |
Dumps docstrings to stdout Only works for top-level definitions and the whole program doc (i.e., not enum constants, struct fields, or functions.
Definition at line 573 of file src/contrail-common/sandesh/compiler/main.cc.
void failure | ( | const char * | fmt, |
... | |||
) |
Prints a failure message and exits
fmt | C format string followed by additional arguments |
Definition at line 309 of file src/contrail-common/sandesh/compiler/main.cc.
void generate | ( | t_program * | program, |
const vector< string > & | generator_strings | ||
) |
Generate code
Definition at line 1014 of file src/contrail-common/sandesh/compiler/main.cc.
void generate_all_fingerprints | ( | t_program * | program | ) |
Call generate_fingerprint for every structure and enum.
Definition at line 660 of file src/contrail-common/sandesh/compiler/main.cc.
string include_file | ( | string | filename | ) |
Finds the appropriate file path for the given filename
Definition at line 349 of file src/contrail-common/sandesh/compiler/main.cc.
Parses a program
Definition at line 949 of file src/contrail-common/sandesh/compiler/main.cc.
void pdebug | ( | const char * | fmt, |
... | |||
) |
Prints a debug message from the parser.
fmt | C format string followed by additional arguments |
Definition at line 260 of file src/contrail-common/sandesh/compiler/main.cc.
string program_name | ( | string | filename | ) |
Converts a string filename into a thrift program name
Definition at line 322 of file src/contrail-common/sandesh/compiler/main.cc.
void pverbose | ( | const char * | fmt, |
... | |||
) |
Prints a verbose output mode message
fmt | C format string followed by additional arguments |
Definition at line 277 of file src/contrail-common/sandesh/compiler/main.cc.
void pwarning | ( | int | level, |
const char * | fmt, | ||
... | |||
) |
Prints a warning message
fmt | C format string followed by additional arguments |
Definition at line 292 of file src/contrail-common/sandesh/compiler/main.cc.
void reset_program_doctext_info | ( | ) |
Reset program doctext information after processing a file
Definition at line 408 of file src/contrail-common/sandesh/compiler/main.cc.
char* saferealpath | ( | const char * | path, |
char * | resolved_path | ||
) |
MinGW doesn't have realpath, so use fallback implementation in that case, otherwise this just calls through to realpath
Definition at line 227 of file src/contrail-common/sandesh/compiler/main.cc.
void usage | ( | ) |
Diplays the usage message and then exits with an error code.
Definition at line 719 of file src/contrail-common/sandesh/compiler/main.cc.
void validate_const_rec | ( | std::string | name, |
t_type * | type, | ||
t_const_value * | value | ||
) |
You know, when I started working on Thrift I really thought it wasn't going to become a programming language because it was just a generator and it wouldn't need runtime type information and all that jazz. But then we decided to add constants, and all of a sudden that means runtime type validation and inference, except the "runtime" is the code generator runtime.
Definition at line 767 of file src/contrail-common/sandesh/compiler/main.cc.
void validate_const_type | ( | t_const * | c | ) |
Check the type of the parsed const information against its declared type
Definition at line 921 of file src/contrail-common/sandesh/compiler/main.cc.
void validate_field_value | ( | t_field * | field, |
t_const_value * | cv | ||
) |
Check the type of a default value assigned to a field.
Definition at line 928 of file src/contrail-common/sandesh/compiler/main.cc.
bool validate_throws | ( | t_struct * | throws | ) |
Check that all the elements of a throws block are actually exceptions.
Definition at line 935 of file src/contrail-common/sandesh/compiler/main.cc.
void version | ( | ) |
Prints the version number
Definition at line 708 of file src/contrail-common/sandesh/compiler/main.cc.
void yyerror | ( | const char * | fmt, |
... | |||
) |
Report an error to the user. This is called yyerror for historical reasons (lex and yacc expect the error reporting routine to be called this). Call this function to report any errors to the user. yyerror takes printf style arguments.
fmt | C format string followed by additional arguments |
Definition at line 240 of file src/contrail-common/sandesh/compiler/main.cc.
|
static |
Set to true to debug docstring parsing
Definition at line 566 of file src/contrail-common/sandesh/compiler/main.cc.
int g_allow_64bit_consts = 0 |
Whether or not 64-bit constants will generate a warning.
Definition at line 194 of file src/contrail-common/sandesh/compiler/main.cc.
int g_allow_neg_field_keys |
Whether or not negative field keys are accepted.
Definition at line 189 of file src/contrail-common/sandesh/compiler/main.cc.
bool g_cpp_use_include_prefix = false |
Should C++ include statements use path prefixes for other thrift-generated header files
Definition at line 142 of file src/contrail-common/sandesh/compiler/main.cc.
string g_curdir |
Current directory of file being parsed
Definition at line 126 of file src/contrail-common/sandesh/compiler/main.cc.
string g_curpath |
Current file being parsed
Definition at line 131 of file src/contrail-common/sandesh/compiler/main.cc.
int g_debug = 0 |
Global debug state
Definition at line 147 of file src/contrail-common/sandesh/compiler/main.cc.
char* g_doctext |
The last parsed doctext comment.
Definition at line 172 of file src/contrail-common/sandesh/compiler/main.cc.
int g_doctext_lineno |
The location of the last parsed doctext comment.
Definition at line 177 of file src/contrail-common/sandesh/compiler/main.cc.
vector<string> g_incl_searchpath |
Search path for inclusions
Definition at line 136 of file src/contrail-common/sandesh/compiler/main.cc.
string g_parent_prefix |
Prefix for putting types in parent scope
Definition at line 116 of file src/contrail-common/sandesh/compiler/main.cc.
t_scope* g_parent_scope |
Parent scope to also parse types
Definition at line 111 of file src/contrail-common/sandesh/compiler/main.cc.
PARSE_MODE g_parse_mode |
Parsing pass
Definition at line 121 of file src/contrail-common/sandesh/compiler/main.cc.
t_program* g_program |
Global program tree
Definition at line 62 of file src/contrail-common/sandesh/compiler/main.cc.
char* g_program_doctext_candidate |
The First doctext comment
Definition at line 182 of file src/contrail-common/sandesh/compiler/main.cc.
int g_program_doctext_lineno = 0 |
Definition at line 183 of file src/contrail-common/sandesh/compiler/main.cc.
PROGDOCTEXT_STATUS g_program_doctext_status = INVALID |
Definition at line 184 of file src/contrail-common/sandesh/compiler/main.cc.
t_scope* g_scope |
Global scope
Definition at line 106 of file src/contrail-common/sandesh/compiler/main.cc.
int g_strict = 127 |
Strictness level
Definition at line 152 of file src/contrail-common/sandesh/compiler/main.cc.
char* g_time_str |
Global time string
Definition at line 167 of file src/contrail-common/sandesh/compiler/main.cc.
t_type* g_type_binary |
Definition at line 70 of file src/contrail-common/sandesh/compiler/main.cc.
t_type* g_type_bool |
Definition at line 72 of file src/contrail-common/sandesh/compiler/main.cc.
t_type* g_type_byte |
Definition at line 73 of file src/contrail-common/sandesh/compiler/main.cc.
t_type* g_type_double |
Definition at line 77 of file src/contrail-common/sandesh/compiler/main.cc.
t_type* g_type_i16 |
Definition at line 74 of file src/contrail-common/sandesh/compiler/main.cc.
t_type* g_type_i32 |
Definition at line 75 of file src/contrail-common/sandesh/compiler/main.cc.
t_type* g_type_i64 |
Definition at line 76 of file src/contrail-common/sandesh/compiler/main.cc.
t_type* g_type_slist |
Definition at line 71 of file src/contrail-common/sandesh/compiler/main.cc.
t_type* g_type_string |
Definition at line 69 of file src/contrail-common/sandesh/compiler/main.cc.
t_type* g_type_void |
Global types
Definition at line 68 of file src/contrail-common/sandesh/compiler/main.cc.
int g_verbose = 0 |
Verbose output
Definition at line 162 of file src/contrail-common/sandesh/compiler/main.cc.
int g_warn = 1 |
Warning level
Definition at line 157 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_cocoa = false |
Definition at line 217 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_cpp = false |
Flags to control code generation
Definition at line 199 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_csharp = false |
Definition at line 218 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_delphi = false |
Definition at line 219 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_dense = false |
Definition at line 200 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_erl = false |
Definition at line 214 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_hs = false |
Definition at line 216 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_java = false |
Definition at line 201 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_javabean = false |
Definition at line 202 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_ocaml = false |
Definition at line 215 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_perl = false |
Definition at line 213 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_php = false |
Definition at line 207 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_phpa = false |
Definition at line 210 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_phpi = false |
Definition at line 208 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_phpo = false |
Definition at line 211 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_phps = true |
Definition at line 209 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_py = false |
Definition at line 204 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_py_newstyle = false |
Definition at line 205 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_rb = false |
Definition at line 203 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_recurse = false |
Definition at line 221 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_rest = false |
Definition at line 212 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_st = false |
Definition at line 220 of file src/contrail-common/sandesh/compiler/main.cc.
bool gen_xsd = false |
Definition at line 206 of file src/contrail-common/sandesh/compiler/main.cc.