tizen 2.3.1 release
[external/ragel.git] / ragel / parsedata.h
index fc2b9c0..3e3bfa6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
+ *  Copyright 2001-2008 Adrian Thurston <thurston@complang.org>
  */
 
 /*  This file is part of Ragel.
@@ -24,6 +24,7 @@
 
 #include <iostream>
 #include <limits.h>
+#include <sstream>
 #include "avlmap.h"
 #include "bstmap.h"
 #include "vector.h"
@@ -53,6 +54,8 @@ struct ReItem;
 struct ReOrBlock;
 struct ReOrItem;
 struct LongestMatch;
+struct InputData;
+struct CodeGenData;
 typedef DList<LongestMatch> LmList;
 
 
@@ -148,13 +151,24 @@ struct NameFrame
        NameInst *prevLocalScope;
 };
 
+struct LengthDef
+{
+       LengthDef( char *name )
+               : name(name) {}
+
+       char *name;
+       LengthDef *prev, *next;
+};
+
+typedef DList<LengthDef> LengthDefList;
+
 /* Class to collect information about the machine during the 
  * parse of input. */
 struct ParseData
 {
        /* Create a new parse data object. This is done at the beginning of every
         * fsm specification. */
-       ParseData( char *fileName, char *sectionName, const InputLoc &sectionLoc );
+       ParseData( const char *fileName, char *sectionName, const InputLoc &sectionLoc );
        ~ParseData();
 
        /*
@@ -216,6 +230,7 @@ struct ParseData
        void prepareMachineGen( GraphDictEl *graphDictEl );
        void prepareMachineGenTBWrapped( GraphDictEl *graphDictEl );
        void generateXML( ostream &out );
+       void generateReduced( InputData &inputData );
        FsmAp *sectionGraph;
        bool generatingSectionSubset;
 
@@ -283,7 +298,7 @@ struct ParseData
        InputLoc rangeLowLoc, rangeHighLoc;
 
        /* The name of the file the fsm is from, and the spec name. */
-       char *fileName;
+       const char *fileName;
        char *sectionName;
        InputLoc sectionLoc;
 
@@ -353,6 +368,9 @@ struct ParseData
        KeyOps thisKeyOps;
 
        ExportList exportList;
+       LengthDefList lengthDefList;
+
+       CodeGenData *cgd;
 };
 
 void afterOpMinimize( FsmAp *fsm, bool lastInSeq = true );
@@ -369,51 +387,5 @@ FsmAp *dotStarFsm( ParseData *pd );
 
 void errorStateLabels( const NameSet &locations );
 
-/* Data used by the parser specific to the current file. Supports the include
- * system, since a new parser is executed for each included file. */
-struct InputData
-{
-       InputData( char *fileName, char *includeSpec, char *includeTo ) :
-               pd(0), sectionName(0), defaultParseData(0), 
-               first_line(1), first_column(1), 
-               last_line(1), last_column(0), 
-               fileName(fileName), includeSpec(includeSpec), 
-               includeTo(includeTo), active(true)
-               {}
-
-       /* For collecting a name references. */
-       NameRef nameRef;
-       NameRefList nameRefList;
-
-       /* The parse data. For each fsm spec, the parser collects things that it parses
-        * in data structures in here. */
-       ParseData *pd;
-
-       char *sectionName;
-       ParseData *defaultParseData;
-
-       int first_line;
-       int first_column;
-       int last_line;
-       int last_column;
-
-       char *fileName;
-
-       /* If this is an included file, this contains the specification to search
-        * for. IncludeTo will contain the spec name that does the includng. */
-       char *includeSpec;
-       char *includeTo;
-
-       bool active;
-       InputLoc sectionLoc;
-};
-
-struct Parser;
-
-typedef AvlMap<char*, Parser *, CmpStr> ParserDict;
-typedef AvlMapEl<char*, Parser *> ParserDictEl;
-
-extern ParserDict parserDict;
-
 
-#endif /* _PARSEDATA_H */
+#endif