Minor reorganization, move ParseFile to the lexer
authorChris Lattner <sabre@nondot.org>
Wed, 30 Jul 2003 19:55:10 +0000 (19:55 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 30 Jul 2003 19:55:10 +0000 (19:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7432 91177308-0d34-0410-b5e6-96231b3b80d8

support/tools/TableGen/FileLexer.l
support/tools/TableGen/FileParser.y
utils/TableGen/FileLexer.l
utils/TableGen/FileParser.y

index 7289ca0bbba1bafa42e8fa84787f7a8179fb775a..c61e9ded3f75628a21198c5d2ae620eb6c511493 100644 (file)
@@ -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     \/\/.*
index b82569ab74207b87a1f1e22845b3f156d91c81c0..d1f8308ce474525b5af41cc6a45516041d3cb5c0 100644 (file)
@@ -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 << ": ";
 }
index 7289ca0bbba1bafa42e8fa84787f7a8179fb775a..c61e9ded3f75628a21198c5d2ae620eb6c511493 100644 (file)
@@ -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     \/\/.*
index b82569ab74207b87a1f1e22845b3f156d91c81c0..d1f8308ce474525b5af41cc6a45516041d3cb5c0 100644 (file)
@@ -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 << ": ";
 }