struct Export
{
- Export( char *name, Key key )
+ Export( const char *name, Key key )
: name(name), key(key) {}
- char *name;
+ const char *name;
Key key;
Export *prev, *next;
{
public:
- Action( const InputLoc &loc, char *name, InlineList *inlineList, int condId )
+ Action( const InputLoc &loc, const char *name, InlineList *inlineList, int condId )
:
loc(loc),
name(name),
}
/* Key for action dictionary. */
- char *getKey() const { return name; }
+ const char *getKey() const { return name; }
/* Data collected during parse. */
InputLoc loc;
- char *name;
+ const char *name;
InlineList *inlineList;
int actionId;
bool frontendOnly = false;
bool generateDot = false;
-typedef Vector<char*> ArgsVector;
+typedef Vector<const char *> ArgsVector;
ArgsVector frontendArgs;
ArgsVector backendArgs;
char *makeIntermedTemplate( char *baseFileName )
{
- char *result = 0, *templ = "ragel-XXXXXX.xml";
+ char *result = 0;
+ const char *templ = "ragel-XXXXXX.xml";
char *lastSlash = strrchr( baseFileName, '/' );
if ( lastSlash == 0 ) {
result = new char[strlen(templ)+1];
}
-void forkAndExec( char *progName, char **pathChecks,
+void forkAndExec( const char *progName, char **pathChecks,
ArgsVector &args, char *intermed )
{
pid_t pid = fork();
else if ( pid == 0 ) {
/* child */
while ( *pathChecks != 0 ) {
- execv( *pathChecks, args.data );
+ /* Execv does not modify argv, it just uses the const form that is
+ * compatible with the most code. Ours not included. */
+ execv( *pathChecks, (char *const*) args.data );
pathChecks += 1;
}
error() << "failed to exec " << progName << endl;
void execFrontend( const char *argv0, char *inputFileName, char *intermed )
{
/* The frontend program name. */
- char *progName = "ragel";
+ const char *progName = "ragel";
frontendArgs.insert( 0, progName );
frontendArgs.insert( 1, "-f" );
void execBackend( const char *argv0, char *intermed, char *outputFileName )
{
/* Locate the backend program */
- char *progName = 0;
+ const char *progName = 0;
if ( generateDot )
progName = "rlgen-dot";
else {
/* Make a name id in the current name instantiation scope if it is not
* already there. */
-NameInst *ParseData::addNameInst( const InputLoc &loc, char *data, bool isLabel )
+NameInst *ParseData::addNameInst( const InputLoc &loc, const char *data, bool isLabel )
{
/* Create the name instantitaion object and insert it. */
NameInst *newNameInst = new NameInst( loc, curNameInst, data, nextNameId++, isLabel );
}
}
-NameSet ParseData::resolvePart( NameInst *refFrom, char *data, bool recLabelsOnly )
+NameSet ParseData::resolvePart( NameInst *refFrom, const char *data, bool recLabelsOnly )
{
/* Queue needed for breadth-first search, load it with the start node. */
NameInstList nameQueue;
}
-void ParseData::createBuiltin( char *name, BuiltinMachine builtin )
+void ParseData::createBuiltin( const char *name, BuiltinMachine builtin )
{
Expression *expression = new Expression( builtin );
Join *join = new Join( expression );
}
}
-Action *ParseData::newAction( char *name, InlineList *inlineList )
+Action *ParseData::newAction( const char *name, InlineList *inlineList )
{
InputLoc loc;
loc.line = 1;
/* Show that the name index is correct. */
for ( int ni = 0; ni < nextNameId; ni++ ) {
cerr << ni << ": ";
- char *name = nameIndex[ni]->name;
+ const char *name = nameIndex[ni]->name;
cerr << ( name != 0 ? name : "<ANON>" ) << endl;
}
}
public AvlTreeEl<GraphDictEl>,
public DListEl<GraphDictEl>
{
- GraphDictEl( char *k )
+ GraphDictEl( const char *k )
: key(k), value(0), isInstance(false) { }
- GraphDictEl( char *k, VarDef *value )
+ GraphDictEl( const char *k, VarDef *value )
: key(k), value(value), isInstance(false) { }
const char *getKey() { return key; }
- char *key;
+ const char *key;
VarDef *value;
bool isInstance;
InputLoc loc;
};
-typedef AvlTree<GraphDictEl, char*, CmpStr> GraphDict;
+typedef AvlTree<GraphDictEl, const char*, CmpStr> GraphDict;
typedef DList<GraphDictEl> GraphList;
/* Priority name dictionary. */
typedef AvlMap<char*, int, CmpStr> PriorDict;
/* Local error name dictionary. */
-typedef AvlMapEl<char*, int> LocalErrDictEl;
-typedef AvlMap<char*, int, CmpStr> LocalErrDict;
+typedef AvlMapEl<const char*, int> LocalErrDictEl;
+typedef AvlMap<const char*, int, CmpStr> LocalErrDict;
/* Tree of instantiated names. */
-typedef BstMapEl<char*, NameInst*> NameMapEl;
-typedef BstMap<char*, NameInst*, CmpStr> NameMap;
+typedef BstMapEl<const char*, NameInst*> NameMapEl;
+typedef BstMap<const char*, NameInst*, CmpStr> NameMap;
typedef Vector<NameInst*> NameVect;
typedef BstSet<NameInst*> NameSet;
/* Node in the tree of instantiated names. */
struct NameInst
{
- NameInst( const InputLoc &loc, NameInst *parent, char *name, int id, bool isLabel ) :
+ NameInst( const InputLoc &loc, NameInst *parent, const char *name, int id, bool isLabel ) :
loc(loc), parent(parent), name(name), id(id), isLabel(isLabel),
isLongestMatch(false), numRefs(0), numUses(0), start(0), final(0) {}
* fully qulified names. */
NameInst *parent;
- char *name;
+ const char *name;
int id;
bool isLabel;
bool isLongestMatch;
/* Initialize a graph dict with the basic fsms. */
void initGraphDict();
- void createBuiltin( char *name, BuiltinMachine builtin );
+ void createBuiltin( const char *name, BuiltinMachine builtin );
/* Make a name id in the current name instantiation scope if it is not
* already there. */
- NameInst *addNameInst( const InputLoc &loc, char *data, bool isLabel );
+ NameInst *addNameInst( const InputLoc &loc, const char *data, bool isLabel );
void makeRootNames();
void makeNameTree( GraphDictEl *gdNode );
void makeExportsNameTree();
void unsetObsoleteEntries( FsmAp *graph );
/* Resove name references in action code and epsilon transitions. */
- NameSet resolvePart( NameInst *refFrom, char *data, bool recLabelsOnly );
+ NameSet resolvePart( NameInst *refFrom, const char *data, bool recLabelsOnly );
void resolveFrom( NameSet &result, NameInst *refFrom,
const NameRef &nameRef, int namePos );
NameInst *resolveStateRef( const NameRef &nameRef, InputLoc &loc, Action *action );
/* List of all longest match parse tree items. */
LmList lmList;
- Action *newAction( char *name, InlineList *inlineList );
+ Action *newAction( const char *name, InlineList *inlineList );
Action *initTokStart;
int initTokStartOrd;
*/
Action *LongestMatch::newAction( ParseData *pd, const InputLoc &loc,
- char *name, InlineList *inlineList )
+ const char *name, InlineList *inlineList )
{
Action *action = new Action( loc, name, inlineList, pd->nextCondId++ );
action->actionRefs.append( pd->curNameInst );
*/
struct VarDef
{
- VarDef( char *name, JoinOrLm *joinOrLm )
+ VarDef( const char *name, JoinOrLm *joinOrLm )
: name(name), joinOrLm(joinOrLm), isExport(false) { }
/* Parse tree traversal. */
void makeNameTree( const InputLoc &loc, ParseData *pd );
void resolveNameRefs( ParseData *pd );
- char *name;
+ const char *name;
JoinOrLm *joinOrLm;
bool isExport;
};
void makeNameTree( ParseData *pd );
void resolveNameRefs( ParseData *pd );
void runLonestMatch( ParseData *pd, FsmAp *graph );
- Action *newAction( ParseData *pd, const InputLoc &loc, char *name,
+ Action *newAction( ParseData *pd, const InputLoc &loc, const char *name,
InlineList *inlineList );
void makeActions( ParseData *pd );
void findName( ParseData *pd );
InputLoc loc;
LmPartList *longestMatchList;
- char *name;
+ const char *name;
Action *lmActSelect;
bool lmSwitchHandlesError;
/* Location in an input file. */
struct InputLoc
{
- char *fileName;
+ const char *fileName;
int line;
int col;
};