goto.h (ragel-7.0.0.10) | : | goto.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. | |||
* | * | |||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |||
* SOFTWARE. | * SOFTWARE. | |||
*/ | */ | |||
#ifndef _GOTO_H | #ifndef _C_GOTO_H | |||
#define _GOTO_H | #define _C_GOTO_H | |||
#include <iostream> | #include <iostream> | |||
#include "codegen.h" | #include "codegen.h" | |||
/* Forwards. */ | /* Forwards. */ | |||
struct CodeGenData; | struct CodeGenData; | |||
struct NameInst; | struct NameInst; | |||
struct RedTransAp; | struct RedTransAp; | |||
struct RedStateAp; | struct RedStateAp; | |||
struct GenStateCond; | struct GenStateCond; | |||
/* | /* | |||
* Goto driven fsm. | * Goto driven fsm. | |||
*/ | */ | |||
class Goto | class Goto | |||
: public CodeGen | : public CodeGen | |||
{ | { | |||
public: | public: | |||
Goto( const CodeGenArgs &args ); | enum Type { | |||
Loop = 1, | ||||
Exp, | ||||
Ip | ||||
}; | ||||
Goto( const CodeGenArgs &args, Type type ) | ||||
: | ||||
CodeGen( args ), | ||||
type(type), | ||||
acts( "_acts" ), | ||||
nacts( "_nacts" ), | ||||
actions( "actions", *this ), | ||||
toStateActions( "to_state_actions", *this ), | ||||
fromStateActions( "from_state_actions", *this ), | ||||
eofActions( "eof_actions", *this ), | ||||
nfaTargs( "nfa_targs", *this ), | ||||
nfaOffsets( "nfa_offsets", *this ), | ||||
nfaPushActions( "nfa_push_actions", *this ), | ||||
nfaPopTrans( "nfa_pop_trans", *this ) | ||||
{} | ||||
void tableDataPass(); | ||||
virtual void genAnalysis(); | ||||
virtual void writeData(); | ||||
virtual void writeExec(); | ||||
std::ostream &TRANSITION( RedCondPair *pair ); | std::ostream &TRANSITION( RedCondPair *pair ); | |||
std::ostream &STATE_GOTOS(); | std::ostream &STATE_GOTOS(); | |||
std::ostream &TRANSITIONS(); | std::ostream &TRANSITIONS(); | |||
std::ostream &FINISH_CASES(); | ||||
Type type; | ||||
Variable acts; | ||||
Variable nacts; | ||||
TableArray actions; | TableArray actions; | |||
TableArray toStateActions; | TableArray toStateActions; | |||
TableArray fromStateActions; | TableArray fromStateActions; | |||
TableArray eofActions; | TableArray eofActions; | |||
TableArray nfaTargs; | TableArray nfaTargs; | |||
TableArray nfaOffsets; | TableArray nfaOffsets; | |||
TableArray nfaPushActions; | TableArray nfaPushActions; | |||
TableArray nfaPopTrans; | TableArray nfaPopTrans; | |||
skipping to change at line 88 | skipping to change at line 117 | |||
void TARGS( ostream &ret, bool inFinish, int targState ); | void TARGS( ostream &ret, bool inFinish, int targState ); | |||
void RET( ostream &ret, bool inFinish ); | void RET( ostream &ret, bool inFinish ); | |||
void NRET( ostream &ret, bool inFinish ); | void NRET( ostream &ret, bool inFinish ); | |||
void BREAK( ostream &ret, int targState, bool csForced ); | void BREAK( ostream &ret, int targState, bool csForced ); | |||
void NBREAK( ostream &ret, int targState, bool csForced ); | void NBREAK( ostream &ret, int targState, bool csForced ); | |||
virtual unsigned int TO_STATE_ACTION( RedStateAp *state ); | virtual unsigned int TO_STATE_ACTION( RedStateAp *state ); | |||
virtual unsigned int FROM_STATE_ACTION( RedStateAp *state ); | virtual unsigned int FROM_STATE_ACTION( RedStateAp *state ); | |||
virtual unsigned int EOF_ACTION( RedStateAp *state ); | virtual unsigned int EOF_ACTION( RedStateAp *state ); | |||
std::ostream &ACTIONS_ARRAY(); | virtual std::ostream &EXEC_FUNCS() = 0; | |||
virtual std::ostream &TO_STATE_ACTION_SWITCH() = 0; | ||||
virtual std::ostream &FROM_STATE_ACTION_SWITCH() = 0; | ||||
virtual std::ostream &EOF_ACTION_SWITCH() = 0; | ||||
std::ostream &TO_STATE_ACTIONS(); | std::ostream &ACTIONS_ARRAY(); | |||
std::ostream &FROM_STATE_ACTIONS(); | ||||
std::ostream &EOF_ACTIONS(); | ||||
void setTableState( TableArray::State ); | void setTableState( TableArray::State ); | |||
virtual std::ostream &COND_GOTO( RedCondPair *trans, int level ); | virtual std::ostream &COND_GOTO( RedCondPair *trans, int level ); | |||
string CKEY( CondKey key ); | string CKEY( CondKey key ); | |||
void COND_B_SEARCH( RedTransAp *trans, int level, CondKey lower, CondKey upper, int low, int high); | void COND_B_SEARCH( RedTransAp *trans, int level, CondKey lower, CondKey upper, int low, int high); | |||
virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level ); | virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level ); | |||
skipping to change at line 114 | skipping to change at line 144 | |||
void RANGE_B_SEARCH( RedStateAp *state, int level, Key lower, Key upper, int low, int high ); | void RANGE_B_SEARCH( RedStateAp *state, int level, Key lower, Key upper, int low, int high ); | |||
/* Called from STATE_GOTOS just before writing the gotos */ | /* Called from STATE_GOTOS just before writing the gotos */ | |||
virtual void GOTO_HEADER( RedStateAp *state ); | virtual void GOTO_HEADER( RedStateAp *state ); | |||
virtual void STATE_GOTO_ERROR(); | virtual void STATE_GOTO_ERROR(); | |||
virtual void NFA_PUSH_ACTION( RedNfaTarg *targ ) = 0; | virtual void NFA_PUSH_ACTION( RedNfaTarg *targ ) = 0; | |||
virtual void NFA_POP_TEST( RedNfaTarg *targ ) {} | virtual void NFA_POP_TEST( RedNfaTarg *targ ) {} | |||
virtual void NFA_FROM_STATE_ACTION_EXEC() = 0; | virtual void NFA_FROM_STATE_ACTION_EXEC() = 0; | |||
void NFA_PUSH(); | ||||
void NFA_POP(); | void NFA_POP(); | |||
virtual void FROM_STATE_ACTIONS() = 0; | ||||
virtual void TO_STATE_ACTIONS() = 0; | ||||
virtual void REG_ACTIONS() = 0; | ||||
virtual void EOF_ACTIONS() = 0; | ||||
}; | }; | |||
#endif | #endif | |||
End of changes. 8 change blocks. | ||||
10 lines changed or deleted | 44 lines changed or added |