[llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l FileParser.y

Chris Lattner lattner at cs.uiuc.edu
Wed Jul 30 14:56:01 PDT 2003


Changes in directory llvm/utils/TableGen:

FileLexer.l updated: 1.2 -> 1.3
FileParser.y updated: 1.11 -> 1.12

---
Log message:

Minor reorganization, move ParseFile to the lexer


---
Diffs of the changes:

Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.2 llvm/utils/TableGen/FileLexer.l:1.3
--- llvm/utils/TableGen/FileLexer.l:1.2	Wed Jul 30 14:39:36 2003
+++ llvm/utils/TableGen/FileLexer.l	Wed Jul 30 14:55:10 2003
@@ -32,6 +32,28 @@
 
 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: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.11 llvm/utils/TableGen/FileParser.y:1.12
--- llvm/utils/TableGen/FileParser.y:1.11	Wed Jul 30 14:48:02 2003
+++ llvm/utils/TableGen/FileParser.y	Wed Jul 30 14:55:10 2003
@@ -7,43 +7,19 @@
 %{
 #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;
 
 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 << ": ";





More information about the llvm-commits mailing list