"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/codegen.h" between
ragel-7.0.0.10.tar.gz and ragel-7.0.0.11.tar.gz

About: Ragel compiles executable finite state machines from regular languages (C, C++, Obj-C, C#, D, Java, Go and Ruby). Development version.

codegen.h  (ragel-7.0.0.10):codegen.h  (ragel-7.0.0.11)
/* /*
* Copyright 2001-2014 Adrian Thurston <thurston@colm.net> * Copyright 2001-2018 Adrian Thurston <thurston@colm.net>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the * deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is * sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in al l * The above copyright notice and this permission notice shall be included in al l
* copies or substantial portions of the Software. * copies or substantial portions of the Software.
skipping to change at line 56 skipping to change at line 56
struct GenAction; struct GenAction;
struct NameInst; struct NameInst;
struct GenInlineItem; struct GenInlineItem;
struct GenInlineList; struct GenInlineList;
struct RedAction; struct RedAction;
struct LongestMatch; struct LongestMatch;
struct LongestMatchPart; struct LongestMatchPart;
string itoa( int i ); string itoa( int i );
struct Variable
{
Variable( const char *name ) : name(name), isReferenced(false) {}
operator const char *() { isReferenced = true; return name; }
void reference() { isReferenced = true; }
const char *name;
bool isReferenced;
};
struct TableArray; struct TableArray;
typedef Vector<TableArray*> ArrayVector; typedef Vector<TableArray*> ArrayVector;
struct CodeGen; struct CodeGen;
struct TableArray struct TableArray
{ {
enum State { enum State {
InitialState = 1, InitialState = 1,
AnalyzePass, AnalyzePass,
GeneratePass GeneratePass
skipping to change at line 145 skipping to change at line 156
virtual void writeStart(); virtual void writeStart();
virtual void writeFirstFinal(); virtual void writeFirstFinal();
virtual void writeError(); virtual void writeError();
virtual void statsSummary(); virtual void statsSummary();
protected: protected:
friend class TableArray; friend class TableArray;
typedef Vector<TableArray*> ArrayVector; typedef Vector<TableArray*> ArrayVector;
ArrayVector arrayVector; ArrayVector arrayVector;
Variable cpc;
string FSM_NAME(); string FSM_NAME();
string START_STATE_ID(); string START_STATE_ID();
void taActions(); void taActions();
string TABS( int level ); string TABS( int level );
string KEY( Key key ); string KEY( Key key );
string LDIR_PATH( char *path ); string LDIR_PATH( char *path );
void ACTION( ostream &ret, GenAction *action, IlOpts opts ); void ACTION( ostream &ret, GenAction *action, IlOpts opts );
void NFA_CONDITION( ostream &ret, GenAction *condition, bool last ); void NFA_CONDITION( ostream &ret, GenAction *condition, bool last );
void CONDITION( ostream &ret, GenAction *condition ); void CONDITION( ostream &ret, GenAction *condition );
string ALPH_TYPE(); string ALPH_TYPE();
bool isAlphTypeSigned(); bool isAlphTypeSigned();
long long tableData; long long tableData;
RagelBackend backend;
bool stringTables; bool stringTables;
BackendFeature backendFeature;
TableArray nfaTargs;
TableArray nfaOffsets;
TableArray nfaPushActions;
TableArray nfaPopTrans;
virtual string GET_KEY(); virtual string GET_KEY();
string P(); string P();
string PE(); string PE();
string vEOF(); string vEOF();
string ACCESS(); string ACCESS();
string vCS(); string vCS();
string STACK(); string STACK();
string TOP(); string TOP();
string TOKSTART(); string TOKSTART();
string TOKEND(); string TOKEND();
string ACT(); string ACT();
string DATA_PREFIX(); string DATA_PREFIX();
string START() { return DATA_PREFIX() + "start"; } string START() { return DATA_PREFIX() + "start"; }
string ERROR() { return DATA_PREFIX() + "error"; } string ERROR() { return DATA_PREFIX() + "error"; }
string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; } string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; }
/* Declare a variable only if referenced. */
void DECLARE( std::string type, Variable &var, std::string init = "" );
string CAST( string type ); string CAST( string type );
string ARR_TYPE( const TableArray &ta ) string ARR_TYPE( const TableArray &ta )
{ return ta.type; } { return ta.type; }
string ARR_REF( const TableArray &ta ) string ARR_REF( const TableArray &ta )
{ return ta.ref(); } { return ta.ref(); }
void INLINE_EXPR( ostream &ret, GenInlineList *inlineList ); void INLINE_EXPR( ostream &ret, GenInlineList *inlineList );
void INLINE_BLOCK( ostream &ret, GenInlineExpr *inlineExpr ); void INLINE_BLOCK( ostream &ret, GenInlineExpr *inlineExpr );
skipping to change at line 239 skipping to change at line 262
void STATE_IDS(); void STATE_IDS();
string ERROR_STATE(); string ERROR_STATE();
string FIRST_FINAL_STATE(); string FIRST_FINAL_STATE();
string STR( int v ); string STR( int v );
bool outLabelUsed; bool outLabelUsed;
bool testEofUsed; bool testEofUsed;
bool againLabelUsed; bool againLabelUsed;
bool useIndicies;
bool matchCondLabelUsed; bool matchCondLabelUsed;
void VALUE( string type, string name, string value ); void VALUE( string type, string name, string value );
string ACCESS_OPER() string ACCESS_OPER()
{ return ""; } { return backend == Direct ? "" : " -> "; }
string OPEN_HOST_EXPR() string OPEN_HOST_EXPR()
{ return "("; } { return backend == Direct ? "(" : "host( \"-\", 1 ) ={"; }
string OPEN_HOST_EXPR( string fileName, int line ) string OPEN_HOST_EXPR( string fileName, int line )
{ return "("; } {
return backend == Direct ? "(" : "host( \"" + fileName + "\", " +
STR(line) + " ) ={";
}
string CLOSE_HOST_EXPR() string CLOSE_HOST_EXPR()
{ return ")"; } { return backend == Direct ? ")" : "}="; }
string OPEN_HOST_BLOCK( string fileName, int line ) string OPEN_HOST_BLOCK( string fileName, int line )
{ {
if ( lineDirectives ) if ( backend == Direct ) {
return "{\n#line " + STR(line) + " \"" + fileName + "\"\n if ( lineDirectives )
"; return "{\n#line " + STR(line) + " \"" + fileName
else + "\"\n";
return "{\n"; else
return "{\n";
}
else {
return "host( \"" + fileName + "\", " + STR(line) + " ) $
{";
}
} }
string OPEN_HOST_BLOCK( GenInlineExpr *inlineExpr ) string OPEN_HOST_BLOCK( GenInlineExpr *inlineExpr )
{ {
return OPEN_HOST_BLOCK( inlineExpr->loc.fileName, inlineExpr->loc .line ); return OPEN_HOST_BLOCK( inlineExpr->loc.fileName, inlineExpr->loc .line );
} }
string CLOSE_HOST_BLOCK() string CLOSE_HOST_BLOCK()
{ return "}"; } { return backend == Direct ? "}" : "}$"; }
string OPEN_HOST_PLAIN() string OPEN_HOST_PLAIN()
{ return ""; } { return backend == Direct ? "" : "host( \"-\", 1 ) @{"; }
string CLOSE_HOST_PLAIN() string CLOSE_HOST_PLAIN()
{ return ""; } { return backend == Direct ? "" : "}@"; }
string OPEN_GEN_EXPR() string OPEN_GEN_EXPR()
{ return "("; } { return backend == Direct ? "(" : "={"; }
string CLOSE_GEN_EXPR() string CLOSE_GEN_EXPR()
{ return ")"; } { return backend == Direct ? ")" : "}="; }
string OPEN_GEN_BLOCK() string OPEN_GEN_BLOCK()
{ return "{"; } { return backend == Direct ? "{" : "${"; }
string CLOSE_GEN_BLOCK() string CLOSE_GEN_BLOCK()
{ return "}"; } { return backend == Direct ? "}" : "}$"; }
string OPEN_GEN_PLAIN() string OPEN_GEN_PLAIN()
{ return ""; } { return backend == Direct ? "" : "@{"; }
string CLOSE_GEN_PLAIN() string CLOSE_GEN_PLAIN()
{ return ""; } { return backend == Direct ? "" : "}@"; }
string UINT() string UINT()
{ return "unsigned int"; } { return backend == Direct ? "unsigned int" : "uint"; }
string INDEX( string type, string name ) string INDEX( string type, string name )
{ {
return "const " + type + " *" + name; if ( backend == Direct )
return "const " + type + " *" + name;
else
return "index " + type + " " + name;
}
string INDEX( string type )
{
if ( backend == Direct )
return "const " + type + " *";
else
return "index " + type + " ";
} }
string ENTRY() string ENTRY()
{ {
return ""; if ( backend == Direct )
return "";
else
return "entry";
} }
string LABEL( string name ) string LABEL( string name )
{ {
return name + ": "; if ( backend == Direct )
return name + ": ";
else
return "label " + name;
} }
string OFFSET( string arr, string off ) string OFFSET( string arr, string off )
{ {
return "( " + arr + " + (" + off + "))"; if ( backend == Direct )
return "( " + arr + " + (" + off + "))";
else
return "offset( " + arr + ", " + off + " )";
} }
string TRUE() string TRUE()
{ {
return "1"; if ( backend == Direct )
return "1";
else
return "TRUE";
} }
string DEREF( string arr, string off ) string DEREF( string arr, string off )
{ {
return "(*( " + off + "))"; if ( backend == Direct )
return "(*( " + off + "))";
else
return "deref( " + arr + ", " + off + " )";
} }
string CASE( string val ) string CASE( string val )
{ {
return "case " + val + ": "; if ( backend == Direct )
return "case " + val + ": ";
else
return "case " + val;
} }
string DEFAULT() string DEFAULT()
{ {
return "default:"; if ( backend == Direct )
return "default:";
else
return "default";
} }
string CEND( ) string CEND( )
{ {
return " break; "; if ( backend == Direct )
return " break; ";
else
return " ";
} }
string FALLTHROUGH() string FALLTHROUGH()
{ {
return " "; if ( backend == Direct )
return " ";
else
return "fallthrough;";
} }
string NIL() string NIL()
{ {
return "0"; if ( backend == Direct )
return "0";
else
return "nil";
} }
string EXPORT( string type, string name, string value ) string EXPORT( string type, string name, string value )
{ {
return "#define " + name + " " + value; if ( backend == Direct )
return "#define " + name + " " + value;
else
return "export " + type + " " + name + " " + value + ";";
} }
virtual void NFA_PUSH( std::string );
virtual void NFA_POP() = 0;
virtual void LOCATE_TRANS() {}
virtual void EOF_TRANS() {}
virtual void COND_EXEC( std::string expr ) {}
virtual void COND_BIN_SEARCH( Variable &var, TableArray &keys, std::strin
g ok, std::string error ) {}
public: public:
virtual void writeExports(); virtual void writeExports();
}; };
#endif #endif
 End of changes. 35 change blocks. 
33 lines changed or deleted 117 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)