forked from OSchip/llvm-project
* Convert C comments to C++ style (why are some one way, some another?!)
* Delete extra space, extra blank comment lines * Convert function comments to doxygen llvm-svn: 11336
This commit is contained in:
parent
b22186adf0
commit
a01b30bbaa
|
@ -1,4 +1,4 @@
|
||||||
/*===-- FileLexer.l - Scanner for TableGen Files ----------------*- C++ -*-===//
|
//===-- FileLexer.l - Scanner for TableGen Files ----------------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
// This file defines a simple flex scanner for TableGen files. This is pretty
|
// This file defines a simple flex scanner for TableGen files. This is pretty
|
||||||
// straight-forward, except for the magic to handle file inclusion.
|
// straight-forward, except for the magic to handle file inclusion.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===*/
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
%option prefix="File"
|
%option prefix="File"
|
||||||
%option yylineno
|
%option yylineno
|
||||||
|
@ -38,7 +38,8 @@ namespace llvm {
|
||||||
// Global variable recording the location of the include directory
|
// Global variable recording the location of the include directory
|
||||||
std::string IncludeDirectory;
|
std::string IncludeDirectory;
|
||||||
|
|
||||||
// ParseInt - This has to handle the special case of binary numbers 0b0101
|
/// ParseInt - This has to handle the special case of binary numbers 0b0101
|
||||||
|
///
|
||||||
static int ParseInt(const char *Str) {
|
static int ParseInt(const char *Str) {
|
||||||
if (Str[0] == '0' && Str[1] == 'b')
|
if (Str[0] == '0' && Str[1] == 'b')
|
||||||
return strtol(Str+2, 0, 2);
|
return strtol(Str+2, 0, 2);
|
||||||
|
@ -60,7 +61,6 @@ struct IncludeRec {
|
||||||
|
|
||||||
static std::vector<IncludeRec> IncludeStack;
|
static std::vector<IncludeRec> IncludeStack;
|
||||||
|
|
||||||
|
|
||||||
std::ostream &err() {
|
std::ostream &err() {
|
||||||
if (IncludeStack.empty())
|
if (IncludeStack.empty())
|
||||||
return std::cerr << "At end of input: ";
|
return std::cerr << "At end of input: ";
|
||||||
|
@ -72,19 +72,8 @@ std::ostream &err() {
|
||||||
<< Filelineno << ": ";
|
<< Filelineno << ": ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ParseFile - this function begins the parsing of the specified tablegen file.
|
||||||
|
///
|
||||||
//
|
|
||||||
// Function: ParseFile()
|
|
||||||
//
|
|
||||||
// Description:
|
|
||||||
// This function begins the parsing of the specified tablegen file.
|
|
||||||
//
|
|
||||||
// Inputs:
|
|
||||||
// Filename - A string containing the name of the file to parse.
|
|
||||||
// IncludeDir - A string containing the directory from which include
|
|
||||||
// files can be found.
|
|
||||||
//
|
|
||||||
void ParseFile(const std::string &Filename, const std::string & IncludeDir) {
|
void ParseFile(const std::string &Filename, const std::string & IncludeDir) {
|
||||||
FILE *F = stdin;
|
FILE *F = stdin;
|
||||||
if (Filename != "-") {
|
if (Filename != "-") {
|
||||||
|
@ -99,10 +88,8 @@ void ParseFile(const std::string &Filename, const std::string & IncludeDir) {
|
||||||
IncludeStack.push_back(IncludeRec("<stdin>", stdin));
|
IncludeStack.push_back(IncludeRec("<stdin>", stdin));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Record the location of the include directory so that the lexer can find
|
// Record the location of the include directory so that the lexer can find
|
||||||
// it later.
|
// it later.
|
||||||
//
|
|
||||||
IncludeDirectory = IncludeDir;
|
IncludeDirectory = IncludeDir;
|
||||||
|
|
||||||
Filein = F;
|
Filein = F;
|
||||||
|
@ -111,8 +98,9 @@ void ParseFile(const std::string &Filename, const std::string & IncludeDir) {
|
||||||
Filein = stdin;
|
Filein = stdin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleInclude - This function is called when an include directive is
|
/// HandleInclude - This function is called when an include directive is
|
||||||
// encountered in the input stream...
|
/// encountered in the input stream...
|
||||||
|
///
|
||||||
static void HandleInclude(const char *Buffer) {
|
static void HandleInclude(const char *Buffer) {
|
||||||
unsigned Length = yyleng;
|
unsigned Length = yyleng;
|
||||||
assert(Buffer[Length-1] == '"');
|
assert(Buffer[Length-1] == '"');
|
||||||
|
@ -133,14 +121,11 @@ static void HandleInclude(const char *Buffer) {
|
||||||
// Open the new input file...
|
// Open the new input file...
|
||||||
yyin = fopen(Filename.c_str(), "r");
|
yyin = fopen(Filename.c_str(), "r");
|
||||||
if (yyin == 0) {
|
if (yyin == 0) {
|
||||||
//
|
|
||||||
// If we couldn't find the file in the current directory, look for it in
|
// If we couldn't find the file in the current directory, look for it in
|
||||||
// the include directories.
|
// the include directories.
|
||||||
//
|
//
|
||||||
// NOTE:
|
// NOTE: Right now, there is only one directory. We need to eventually add
|
||||||
// Right now, there is only one directory. We need to eventually add
|
// support for more.
|
||||||
// support for more.
|
|
||||||
//
|
|
||||||
Filename = IncludeDirectory + "/" + Filename;
|
Filename = IncludeDirectory + "/" + Filename;
|
||||||
yyin = fopen(Filename.c_str(), "r");
|
yyin = fopen(Filename.c_str(), "r");
|
||||||
if (yyin == 0) {
|
if (yyin == 0) {
|
||||||
|
@ -157,10 +142,9 @@ static void HandleInclude(const char *Buffer) {
|
||||||
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
|
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// yywrap - This is called when the lexer runs out of input in one of the
|
||||||
// yywrap - This is called when the lexer runs out of input in one of the files.
|
/// files. Switch back to an includer if an includee has run out of input.
|
||||||
// Switch back to an includer if an includee has run out of input.
|
///
|
||||||
//
|
|
||||||
extern "C"
|
extern "C"
|
||||||
int yywrap() {
|
int yywrap() {
|
||||||
if (IncludeStack.back().File != stdin)
|
if (IncludeStack.back().File != stdin)
|
||||||
|
|
Loading…
Reference in New Issue