aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/ragel6/cdcodegen.cpp
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:44:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:49 +0300
commit718c552901d703c502ccbefdfc3c9028d608b947 (patch)
tree46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/tools/ragel6/cdcodegen.cpp
parente9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff)
downloadydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/ragel6/cdcodegen.cpp')
-rw-r--r--contrib/tools/ragel6/cdcodegen.cpp320
1 files changed, 160 insertions, 160 deletions
diff --git a/contrib/tools/ragel6/cdcodegen.cpp b/contrib/tools/ragel6/cdcodegen.cpp
index 9e784e3f58..12a8d9316f 100644
--- a/contrib/tools/ragel6/cdcodegen.cpp
+++ b/contrib/tools/ragel6/cdcodegen.cpp
@@ -329,48 +329,48 @@ string FsmCodeGen::KEY( Key key )
return ret.str();
}
-bool FsmCodeGen::isAlphTypeSigned()
-{
- return keyOps->isSigned;
-}
-
-bool FsmCodeGen::isWideAlphTypeSigned()
-{
- string ret;
- if ( redFsm->maxKey <= keyOps->maxKey )
- return isAlphTypeSigned();
- else {
- long long maxKeyVal = redFsm->maxKey.getLongLong();
- HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal );
- return wideType->isSigned;
- }
-}
-
-string FsmCodeGen::WIDE_KEY( RedStateAp *state, Key key )
-{
- if ( state->stateCondList.length() > 0 ) {
- ostringstream ret;
- if ( isWideAlphTypeSigned() )
- ret << key.getVal();
- else
- ret << (unsigned long) key.getVal() << 'u';
- return ret.str();
- }
- else {
- return KEY( key );
- }
-}
-
-void FsmCodeGen::EOF_CHECK( ostream &ret )
-{
- ret <<
- " if ( " << P() << " == " << PE() << " )\n"
- " goto _test_eof;\n";
-
- testEofUsed = true;
-}
-
-
+bool FsmCodeGen::isAlphTypeSigned()
+{
+ return keyOps->isSigned;
+}
+
+bool FsmCodeGen::isWideAlphTypeSigned()
+{
+ string ret;
+ if ( redFsm->maxKey <= keyOps->maxKey )
+ return isAlphTypeSigned();
+ else {
+ long long maxKeyVal = redFsm->maxKey.getLongLong();
+ HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal );
+ return wideType->isSigned;
+ }
+}
+
+string FsmCodeGen::WIDE_KEY( RedStateAp *state, Key key )
+{
+ if ( state->stateCondList.length() > 0 ) {
+ ostringstream ret;
+ if ( isWideAlphTypeSigned() )
+ ret << key.getVal();
+ else
+ ret << (unsigned long) key.getVal() << 'u';
+ return ret.str();
+ }
+ else {
+ return KEY( key );
+ }
+}
+
+void FsmCodeGen::EOF_CHECK( ostream &ret )
+{
+ ret <<
+ " if ( " << P() << " == " << PE() << " )\n"
+ " goto _test_eof;\n";
+
+ testEofUsed = true;
+}
+
+
void FsmCodeGen::EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish )
{
/* The parser gives fexec two children. The double brackets are for D
@@ -405,7 +405,7 @@ void FsmCodeGen::LM_SWITCH( ostream &ret, GenInlineItem *item,
ret << " break;\n";
}
- if ( (hostLang->lang == HostLang::D || hostLang->lang == HostLang::D2) && !haveDefault )
+ if ( (hostLang->lang == HostLang::D || hostLang->lang == HostLang::D2) && !haveDefault )
ret << " default: break;";
ret <<
@@ -664,7 +664,7 @@ void FsmCodeGen::STATE_IDS()
out << "\n";
- if ( !noEntry && entryPointNames.length() > 0 ) {
+ if ( !noEntry && entryPointNames.length() > 0 ) {
for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) {
STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) <<
" = " << entryPointIds[en.pos()] << "};\n";
@@ -697,11 +697,11 @@ string CCodeGen::PTR_CONST()
return "const ";
}
-string CCodeGen::PTR_CONST_END()
-{
- return "";
-}
-
+string CCodeGen::PTR_CONST_END()
+{
+ return "";
+}
+
std::ostream &CCodeGen::OPEN_ARRAY( string type, string name )
{
out << "#if defined(__GNUC__)\n";
@@ -789,11 +789,11 @@ string DCodeGen::PTR_CONST()
return "";
}
-string DCodeGen::PTR_CONST_END()
-{
- return "";
-}
-
+string DCodeGen::PTR_CONST_END()
+{
+ return "";
+}
+
std::ostream &DCodeGen::OPEN_ARRAY( string type, string name )
{
out << "static const " << type << "[] " << name << " = [\n";
@@ -852,112 +852,112 @@ void DCodeGen::writeExports()
* End D-specific code.
*/
-/*
- * D2 Specific
- */
-
-string D2CodeGen::NULL_ITEM()
-{
- return "null";
-}
-
-string D2CodeGen::POINTER()
-{
- // multiple items seperated by commas can also be pointer types.
- return "* ";
-}
-
-string D2CodeGen::PTR_CONST()
-{
- return "const(";
-}
-
-string D2CodeGen::PTR_CONST_END()
-{
- return ")";
-}
-
-std::ostream &D2CodeGen::OPEN_ARRAY( string type, string name )
-{
- out << "enum " << type << "[] " << name << " = [\n";
- return out;
-}
-
-std::ostream &D2CodeGen::CLOSE_ARRAY()
-{
- return out << "];\n";
-}
-
-std::ostream &D2CodeGen::STATIC_VAR( string type, string name )
-{
- out << "enum " << type << " " << name;
- return out;
-}
-
-string D2CodeGen::ARR_OFF( string ptr, string offset )
-{
- return "&" + ptr + "[" + offset + "]";
-}
-
-string D2CodeGen::CAST( string type )
-{
- return "cast(" + type + ")";
-}
-
-string D2CodeGen::UINT( )
-{
- return "uint";
-}
-
-std::ostream &D2CodeGen::SWITCH_DEFAULT()
-{
- out << " default: break;\n";
- return out;
-}
-
-string D2CodeGen::CTRL_FLOW()
-{
- return "if (true) ";
-}
-
-void D2CodeGen::writeExports()
-{
- if ( exportList.length() > 0 ) {
- for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) {
- out << "enum " << ALPH_TYPE() << " " << DATA_PREFIX() <<
- "ex_" << ex->name << " = " << KEY(ex->key) << ";\n";
- }
- out << "\n";
- }
-}
-
-void D2CodeGen::SUB_ACTION( ostream &ret, GenInlineItem *item,
- int targState, bool inFinish, bool csForced )
-{
- if ( item->children->length() > 0 ) {
- /* Write the block and close it off. */
- ret << "{{";
- INLINE_LIST( ret, item->children, targState, inFinish, csForced );
- ret << "}}";
- }
-}
-
-void D2CodeGen::ACTION( ostream &ret, GenAction *action, int targState,
- bool inFinish, bool csForced )
-{
- /* Write the preprocessor line info for going into the source file. */
- cdLineDirective( ret, action->loc.fileName, action->loc.line );
-
- /* Write the block and close it off. */
- ret << "\t{{";
- INLINE_LIST( ret, action->inlineList, targState, inFinish, csForced );
- ret << "}}\n";
-}
-
-/*
- * End D2-specific code.
- */
-
+/*
+ * D2 Specific
+ */
+
+string D2CodeGen::NULL_ITEM()
+{
+ return "null";
+}
+
+string D2CodeGen::POINTER()
+{
+ // multiple items seperated by commas can also be pointer types.
+ return "* ";
+}
+
+string D2CodeGen::PTR_CONST()
+{
+ return "const(";
+}
+
+string D2CodeGen::PTR_CONST_END()
+{
+ return ")";
+}
+
+std::ostream &D2CodeGen::OPEN_ARRAY( string type, string name )
+{
+ out << "enum " << type << "[] " << name << " = [\n";
+ return out;
+}
+
+std::ostream &D2CodeGen::CLOSE_ARRAY()
+{
+ return out << "];\n";
+}
+
+std::ostream &D2CodeGen::STATIC_VAR( string type, string name )
+{
+ out << "enum " << type << " " << name;
+ return out;
+}
+
+string D2CodeGen::ARR_OFF( string ptr, string offset )
+{
+ return "&" + ptr + "[" + offset + "]";
+}
+
+string D2CodeGen::CAST( string type )
+{
+ return "cast(" + type + ")";
+}
+
+string D2CodeGen::UINT( )
+{
+ return "uint";
+}
+
+std::ostream &D2CodeGen::SWITCH_DEFAULT()
+{
+ out << " default: break;\n";
+ return out;
+}
+
+string D2CodeGen::CTRL_FLOW()
+{
+ return "if (true) ";
+}
+
+void D2CodeGen::writeExports()
+{
+ if ( exportList.length() > 0 ) {
+ for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) {
+ out << "enum " << ALPH_TYPE() << " " << DATA_PREFIX() <<
+ "ex_" << ex->name << " = " << KEY(ex->key) << ";\n";
+ }
+ out << "\n";
+ }
+}
+
+void D2CodeGen::SUB_ACTION( ostream &ret, GenInlineItem *item,
+ int targState, bool inFinish, bool csForced )
+{
+ if ( item->children->length() > 0 ) {
+ /* Write the block and close it off. */
+ ret << "{{";
+ INLINE_LIST( ret, item->children, targState, inFinish, csForced );
+ ret << "}}";
+ }
+}
+
+void D2CodeGen::ACTION( ostream &ret, GenAction *action, int targState,
+ bool inFinish, bool csForced )
+{
+ /* Write the preprocessor line info for going into the source file. */
+ cdLineDirective( ret, action->loc.fileName, action->loc.line );
+
+ /* Write the block and close it off. */
+ ret << "\t{{";
+ INLINE_LIST( ret, action->inlineList, targState, inFinish, csForced );
+ ret << "}}\n";
+}
+
+/*
+ * End D2-specific code.
+ */
+
void FsmCodeGen::finishRagelDef()
{
if ( codeStyle == GenGoto || codeStyle == GenFGoto ||