mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-26 21:20:29 +00:00
Minor reorganization, move ParseFile to the lexer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7432 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
90523906fa
commit
e623fe3d0a
@ -32,6 +32,28 @@ static int ParseInt(const char *Str) {
|
||||
|
||||
static int CommentDepth = 0;
|
||||
|
||||
int Fileparse();
|
||||
|
||||
void ParseFile(const std::string &Filename) {
|
||||
FILE *F = stdin;
|
||||
if (Filename != "-") {
|
||||
F = fopen(Filename.c_str(), "r");
|
||||
|
||||
if (F == 0) {
|
||||
std::cerr << "Could not open input file '" + Filename + "'!\n";
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
Filein = F;
|
||||
Filelineno = 1;
|
||||
Fileparse();
|
||||
|
||||
if (F != stdin)
|
||||
fclose(F);
|
||||
Filein = stdin;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
Comment \/\/.*
|
||||
|
@ -7,16 +7,13 @@
|
||||
%{
|
||||
#include "Record.h"
|
||||
#include "Support/StringExtras.h"
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#define YYERROR_VERBOSE 1
|
||||
|
||||
int yyerror(const char *ErrorMsg);
|
||||
int yylex();
|
||||
extern FILE *Filein;
|
||||
extern int Filelineno;
|
||||
int Fileparse();
|
||||
static Record *CurRec = 0;
|
||||
|
||||
typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
|
||||
@ -24,27 +21,6 @@ typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
|
||||
static std::vector<std::pair<std::pair<std::string, std::vector<unsigned>*>,
|
||||
Init*> > SetStack;
|
||||
|
||||
void ParseFile(const std::string &Filename) {
|
||||
FILE *F = stdin;
|
||||
if (Filename != "-") {
|
||||
F = fopen(Filename.c_str(), "r");
|
||||
|
||||
if (F == 0) {
|
||||
std::cerr << "Could not open input file '" + Filename + "'!\n";
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Filein = F;
|
||||
Filelineno = 1;
|
||||
Fileparse();
|
||||
|
||||
if (F != stdin)
|
||||
fclose(F);
|
||||
Filein = stdin;
|
||||
}
|
||||
|
||||
static std::ostream &err() {
|
||||
return std::cerr << "Parsing Line #" << Filelineno << ": ";
|
||||
}
|
||||
|
@ -32,6 +32,28 @@ static int ParseInt(const char *Str) {
|
||||
|
||||
static int CommentDepth = 0;
|
||||
|
||||
int Fileparse();
|
||||
|
||||
void ParseFile(const std::string &Filename) {
|
||||
FILE *F = stdin;
|
||||
if (Filename != "-") {
|
||||
F = fopen(Filename.c_str(), "r");
|
||||
|
||||
if (F == 0) {
|
||||
std::cerr << "Could not open input file '" + Filename + "'!\n";
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
Filein = F;
|
||||
Filelineno = 1;
|
||||
Fileparse();
|
||||
|
||||
if (F != stdin)
|
||||
fclose(F);
|
||||
Filein = stdin;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
Comment \/\/.*
|
||||
|
@ -7,16 +7,13 @@
|
||||
%{
|
||||
#include "Record.h"
|
||||
#include "Support/StringExtras.h"
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#define YYERROR_VERBOSE 1
|
||||
|
||||
int yyerror(const char *ErrorMsg);
|
||||
int yylex();
|
||||
extern FILE *Filein;
|
||||
extern int Filelineno;
|
||||
int Fileparse();
|
||||
static Record *CurRec = 0;
|
||||
|
||||
typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
|
||||
@ -24,27 +21,6 @@ typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
|
||||
static std::vector<std::pair<std::pair<std::string, std::vector<unsigned>*>,
|
||||
Init*> > SetStack;
|
||||
|
||||
void ParseFile(const std::string &Filename) {
|
||||
FILE *F = stdin;
|
||||
if (Filename != "-") {
|
||||
F = fopen(Filename.c_str(), "r");
|
||||
|
||||
if (F == 0) {
|
||||
std::cerr << "Could not open input file '" + Filename + "'!\n";
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Filein = F;
|
||||
Filelineno = 1;
|
||||
Fileparse();
|
||||
|
||||
if (F != stdin)
|
||||
fclose(F);
|
||||
Filein = stdin;
|
||||
}
|
||||
|
||||
static std::ostream &err() {
|
||||
return std::cerr << "Parsing Line #" << Filelineno << ": ";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user