From d13d67a31c451ebd78ce708a4ef85803d429f158 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Fri, 24 Mar 2017 04:52:08 +0000 Subject: ragel-6.10 --- ragel/Makefile.in | 27 +++++++++++----- ragel/cdcodegen.cpp | 10 +++++- ragel/cdcodegen.h | 2 ++ ragel/cdflat.cpp | 52 +++++++++++++++++++++++++----- ragel/cdgoto.cpp | 56 +++++++++++++++++++++++++++------ ragel/cdipgoto.cpp | 71 +++++++++++++++++++++++++++++++++++------ ragel/cdipgoto.h | 2 ++ ragel/cdtable.cpp | 54 ++++++++++++++++++++++++++------ ragel/common.cpp | 87 +++++++++++++++++++++++++-------------------------- ragel/common.h | 29 +++++++++++------ ragel/config.h.in | 2 +- ragel/cscodegen.cpp | 2 +- ragel/cstable.cpp | 41 ++++++++++++++++++------ ragel/fsmgraph.h | 8 ++--- ragel/gendata.cpp | 7 +++++ ragel/gendata.h | 1 + ragel/gocodegen.cpp | 2 +- ragel/javacodegen.cpp | 2 +- ragel/mlcodegen.cpp | 2 +- ragel/parsedata.cpp | 63 ++++++++++++++++++++++++------------- ragel/parsetree.cpp | 2 -- ragel/parsetree.h | 4 +-- ragel/rbxgoto.cpp | 2 +- ragel/redfsm.cpp | 1 + ragel/redfsm.h | 2 ++ ragel/rubycodegen.cpp | 2 +- ragel/version.h | 4 +-- 27 files changed, 389 insertions(+), 148 deletions(-) (limited to 'ragel') diff --git a/ragel/Makefile.in b/ragel/Makefile.in index 8760e48..5d3c8fb 100644 --- a/ragel/Makefile.in +++ b/ragel/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -78,12 +88,11 @@ PRE_UNINSTALL = : POST_UNINSTALL = : bin_PROGRAMS = ragel$(EXEEXT) subdir = ragel -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/config.h.in $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = @@ -195,6 +204,8 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ @@ -290,6 +301,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -347,7 +359,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ragel/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign ragel/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -1526,6 +1537,8 @@ uninstall-am: uninstall-binPROGRAMS mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-binPROGRAMS +.PRECIOUS: Makefile + version.h: Makefile echo '#define VERSION "$(PACKAGE_VERSION)"' > version.h diff --git a/ragel/cdcodegen.cpp b/ragel/cdcodegen.cpp index 3d7cafc..96d8501 100644 --- a/ragel/cdcodegen.cpp +++ b/ragel/cdcodegen.cpp @@ -361,6 +361,14 @@ string FsmCodeGen::WIDE_KEY( RedStateAp *state, 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 ) @@ -656,7 +664,7 @@ void FsmCodeGen::STATE_IDS() out << "\n"; - if ( 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"; diff --git a/ragel/cdcodegen.h b/ragel/cdcodegen.h index d8fe62d..b9a8490 100644 --- a/ragel/cdcodegen.h +++ b/ragel/cdcodegen.h @@ -131,6 +131,8 @@ protected: string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; } string CTXDATA() { return DATA_PREFIX() + "ctxdata"; } + void EOF_CHECK( ostream &ret ); + void INLINE_LIST( ostream &ret, GenInlineList *inlineList, int targState, bool inFinish, bool csForced ); virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ) = 0; diff --git a/ragel/cdflat.cpp b/ragel/cdflat.cpp index 6010f98..b28a95a 100644 --- a/ragel/cdflat.cpp +++ b/ragel/cdflat.cpp @@ -454,15 +454,32 @@ void FlatCodeGen::LOCATE_TRANS() void FlatCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) { - ret << "{" << vCS() << " = " << gotoDest << "; " << - CTRL_FLOW() << "goto _again;}"; + ret << "{"; + + ret << vCS() << " = " << gotoDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void FlatCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) { - ret << "{" << vCS() << " = ("; + ret << "{"; + + ret << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << "); " << CTRL_FLOW() << "goto _again;}"; + ret << "); "; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void FlatCodeGen::CURS( ostream &ret, bool inFinish ) @@ -494,8 +511,16 @@ void FlatCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << - callDest << "; " << CTRL_FLOW() << "goto _again;}"; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; if ( prePushExpr != 0 ) ret << "}"; @@ -511,7 +536,13 @@ void FlatCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, targState, inFinish, false ); - ret << "); " << CTRL_FLOW() << "goto _again;}"; + ret << ");"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + ret << "}"; if ( prePushExpr != 0 ) ret << "}"; @@ -528,7 +559,12 @@ void FlatCodeGen::RET( ostream &ret, bool inFinish ) ret << "}"; } - ret << CTRL_FLOW() << "goto _again;}"; + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void FlatCodeGen::BREAK( ostream &ret, int targState, bool csForced ) diff --git a/ragel/cdgoto.cpp b/ragel/cdgoto.cpp index e434143..86b3d23 100644 --- a/ragel/cdgoto.cpp +++ b/ragel/cdgoto.cpp @@ -543,15 +543,32 @@ std::ostream &GotoCodeGen::FINISH_CASES() void GotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) { - ret << "{" << vCS() << " = " << gotoDest << "; " << - CTRL_FLOW() << "goto _again;}"; + ret << "{"; + + ret << vCS() << " = " << gotoDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void GotoCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) { - ret << "{" << vCS() << " = ("; + ret << "{"; + + ret << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << "); " << CTRL_FLOW() << "goto _again;}"; + ret << ");"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void GotoCodeGen::CURS( ostream &ret, bool inFinish ) @@ -583,8 +600,16 @@ void GotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << - callDest << "; " << CTRL_FLOW() << "goto _again;}"; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; if ( prePushExpr != 0 ) ret << "}"; @@ -597,9 +622,18 @@ void GotoCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, targState, inFinish, false ); - ret << "); " << CTRL_FLOW() << "goto _again;}"; + ret << ");"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; if ( prePushExpr != 0 ) ret << "}"; @@ -615,7 +649,11 @@ void GotoCodeGen::RET( ostream &ret, bool inFinish ) ret << "}"; } - ret << CTRL_FLOW() << "goto _again;}"; + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + ret << "}"; } void GotoCodeGen::BREAK( ostream &ret, int targState, bool csForced ) diff --git a/ragel/cdipgoto.cpp b/ragel/cdipgoto.cpp index 298bf36..05c9299 100644 --- a/ragel/cdipgoto.cpp +++ b/ragel/cdipgoto.cpp @@ -29,14 +29,30 @@ bool IpGotoCodeGen::useAgainLabel() { - return redFsm->anyRegActionRets() || - redFsm->anyRegActionByValControl() || + return redFsm->anyActionRets() || + redFsm->anyActionByValControl() || redFsm->anyRegNextStmt(); } +void IpGotoCodeGen::EOF_CHECK( ostream &ret, int gotoDest ) +{ + ret << + " if ( " << P() << " == " << PE() << " )\n" + " goto _test_eof" << gotoDest << ";\n"; + + testEofUsed = true; +} + void IpGotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) { - ret << "{" << CTRL_FLOW() << "goto st" << gotoDest << ";}"; + ret << "{"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret, gotoDest ); + + ret << CTRL_FLOW() << "goto st" << gotoDest << ";"; + + ret << "}"; } void IpGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) @@ -46,8 +62,14 @@ void IpGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFini INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << targState << - "; " << CTRL_FLOW() << "goto st" << callDest << ";}"; + ret << "{" << STACK() << "[" << TOP() << "++] = " << targState << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret, callDest ); + + ret << CTRL_FLOW() << "goto st" << callDest << ";"; + + ret << "}"; if ( prePushExpr != 0 ) ret << "}"; @@ -60,9 +82,18 @@ void IpGotoCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targStat INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << targState << "; " << vCS() << " = ("; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << targState << "; " << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << "); " << CTRL_FLOW() << "goto _again;}"; + ret << ");"; + + if ( inFinish && !noEnd ) + FsmCodeGen::EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; if ( prePushExpr != 0 ) ret << "}"; @@ -78,14 +109,27 @@ void IpGotoCodeGen::RET( ostream &ret, bool inFinish ) ret << "}"; } - ret << CTRL_FLOW() << "goto _again;}"; + if ( inFinish && !noEnd ) + FsmCodeGen::EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void IpGotoCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) { - ret << "{" << vCS() << " = ("; + ret << "{"; + + ret << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << "); " << CTRL_FLOW() << "goto _again;}"; + ret << ");"; + + if ( inFinish && !noEnd ) + FsmCodeGen::EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + ret << "}"; } void IpGotoCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) @@ -350,6 +394,13 @@ void IpGotoCodeGen::setLabelsNeeded() } } } + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofAction != 0 ) { + for ( GenActionTable::Iter item = st->eofAction->key; item.lte(); item++ ) + setLabelsNeeded( item->value->inlineList ); + } + } } if ( !noEnd ) { diff --git a/ragel/cdipgoto.h b/ragel/cdipgoto.h index c869e1f..4e92926 100644 --- a/ragel/cdipgoto.h +++ b/ragel/cdipgoto.h @@ -60,6 +60,8 @@ public: protected: bool useAgainLabel(); + void EOF_CHECK( ostream &ret, int gotoDest ); + /* Called from GotoCodeGen::STATE_GOTOS just before writing the gotos for * each state. */ bool IN_TRANS_ACTIONS( RedStateAp *state ); diff --git a/ragel/cdtable.cpp b/ragel/cdtable.cpp index 2218839..6bcb79e 100644 --- a/ragel/cdtable.cpp +++ b/ragel/cdtable.cpp @@ -666,15 +666,31 @@ void TabCodeGen::LOCATE_TRANS() void TabCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) { - ret << "{" << vCS() << " = " << gotoDest << "; " << - CTRL_FLOW() << "goto _again;}"; + ret << "{"; + + ret << vCS() << " = " << gotoDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void TabCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) { - ret << "{" << vCS() << " = ("; + ret << "{"; + ret << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << "); " << CTRL_FLOW() << "goto _again;}"; + ret << "); "; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void TabCodeGen::CURS( ostream &ret, bool inFinish ) @@ -706,8 +722,14 @@ void TabCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << - callDest << "; " << CTRL_FLOW() << "goto _again;}"; + ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; if ( prePushExpr != 0 ) ret << "}"; @@ -720,9 +742,18 @@ void TabCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, targState, inFinish, false ); - ret << "); " << CTRL_FLOW() << "goto _again;}"; + ret << ");"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; if ( prePushExpr != 0 ) ret << "}"; @@ -739,7 +770,12 @@ void TabCodeGen::RET( ostream &ret, bool inFinish ) ret << "}"; } - ret << CTRL_FLOW() << "goto _again;}"; + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void TabCodeGen::BREAK( ostream &ret, int targState, bool csForced ) diff --git a/ragel/common.cpp b/ragel/common.cpp index 3047e70..8e9f8ed 100644 --- a/ragel/common.cpp +++ b/ragel/common.cpp @@ -27,14 +27,14 @@ HostType hostTypesC[] = { - { "char", 0, "char", true, true, false, CHAR_MIN, CHAR_MAX, sizeof(char) }, - { "unsigned", "char", "uchar", false, true, false, 0, UCHAR_MAX, sizeof(unsigned char) }, - { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, sizeof(short) }, - { "unsigned", "short", "ushort", false, true, false, 0, USHRT_MAX, sizeof(unsigned short) }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, sizeof(int) }, - { "unsigned", "int", "uint", false, true, false, 0, UINT_MAX, sizeof(unsigned int) }, - { "long", 0, "long", true, true, false, LONG_MIN, LONG_MAX, sizeof(long) }, - { "unsigned", "long", "ulong", false, true, false, 0, ULONG_MAX, sizeof(unsigned long) } + { "char", 0, "char", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, sizeof(char) }, + { "unsigned", "char", "uchar", false, true, false, 0, 0, 0, UCHAR_MAX, sizeof(unsigned char) }, + { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, sizeof(short) }, + { "unsigned", "short", "ushort", false, true, false, 0, 0, 0, USHRT_MAX, sizeof(unsigned short) }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, sizeof(int) }, + { "unsigned", "int", "uint", false, true, false, 0, 0, 0, UINT_MAX, sizeof(unsigned int) }, + { "long", 0, "long", true, true, false, LONG_MIN, LONG_MAX, 0, 0, sizeof(long) }, + { "unsigned", "long", "ulong", false, true, false, 0, 0, 0, ULONG_MAX, sizeof(unsigned long) } }; #define S8BIT_MIN -128 @@ -66,63 +66,62 @@ HostType hostTypesC[] = HostType hostTypesD[] = { - { "byte", 0, "byte", true, true, false, CHAR_MIN, CHAR_MAX, 1 }, - { "ubyte", 0, "ubyte", false, true, false, 0, UCHAR_MAX, 1 }, - { "char", 0, "char", false, true, false, 0, UCHAR_MAX, 1 }, - { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 2 }, - { "ushort", 0, "ushort", false, true, false, 0, USHRT_MAX, 2 }, - { "wchar", 0, "wchar", false, true, false, 0, USHRT_MAX, 2 }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 4 }, - { "uint", 0, "uint", false, true, false, 0, UINT_MAX, 4 }, - { "dchar", 0, "dchar", false, true, false, 0, UINT_MAX, 4 } + { "byte", 0, "byte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, + { "ubyte", 0, "ubyte", false, true, false, 0, 0, 0, UCHAR_MAX, 1 }, + { "char", 0, "char", false, true, false, 0, 0, 0, UCHAR_MAX, 1 }, + { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 }, + { "ushort", 0, "ushort", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, + { "wchar", 0, "wchar", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, + { "uint", 0, "uint", false, true, false, 0, 0, 0, UINT_MAX, 4 }, + { "dchar", 0, "dchar", false, true, false, 0, 0, 0, UINT_MAX, 4 } }; HostType hostTypesGo[] = { - { "byte", 0, "uint8", false, true, false, U8BIT_MIN, U8BIT_MAX, 1 }, - { "int8", 0, "int8", true, true, false, S8BIT_MIN, S8BIT_MAX, 1 }, - { "uint8", 0, "uint8", false, true, false, U8BIT_MIN, U8BIT_MAX, 1 }, - { "int16", 0, "int16", true, true, false, S16BIT_MIN, S16BIT_MAX, 2 }, - { "uint16", 0, "uint16", false, true, false, U16BIT_MIN, U16BIT_MAX, 2 }, - { "int32", 0, "int32", true, true, false, S32BIT_MIN, S32BIT_MAX, 4 }, - { "uint32", 0, "uint32", false, true, false, U32BIT_MIN, U32BIT_MAX, 4 }, - { "int64", 0, "int64", true, true, false, S64BIT_MIN, S64BIT_MAX, 8 }, - { "uint64", 0, "uint64", false, true, false, U64BIT_MIN, U64BIT_MAX, 8 }, - { "rune", 0, "int32", true, true, true, S32BIT_MIN, S32BIT_MAX, 4 } + { "byte", 0, "uint8", false, true, false, 0, 0, U8BIT_MIN, U8BIT_MAX, 1 }, + { "int8", 0, "int8", true, true, false, S8BIT_MIN, S8BIT_MAX, 0, 0, 1 }, + { "uint8", 0, "uint8", false, true, false, 0, 0, U8BIT_MIN, U8BIT_MAX, 1 }, + { "int16", 0, "int16", true, true, false, S16BIT_MIN, S16BIT_MAX, 0, 0, 2 }, + { "uint16", 0, "uint16", false, true, false, 0, 0, U16BIT_MIN, U16BIT_MAX, 2 }, + { "int32", 0, "int32", true, true, false, S32BIT_MIN, S32BIT_MAX, 0, 0, 4 }, + { "uint32", 0, "uint32", false, true, false, 0, 0, U32BIT_MIN, U32BIT_MAX, 4 }, + { "int64", 0, "int64", true, true, false, S64BIT_MIN, S64BIT_MAX, 0, 0, 8 }, + { "uint64", 0, "uint64", false, true, false, 0, 0, U64BIT_MIN, U64BIT_MAX, 8 }, + { "rune", 0, "int32", true, true, true, S32BIT_MIN, S32BIT_MAX, 0, 0, 4 } }; HostType hostTypesJava[] = { - { "byte", 0, "byte", true, true, false, CHAR_MIN, CHAR_MAX, 1 }, - { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 2 }, - { "char", 0, "char", false, true, false, 0, USHRT_MAX, 2 }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 4 }, + { "byte", 0, "byte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, + { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 }, + { "char", 0, "char", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, }; /* What are the appropriate types for ruby? */ HostType hostTypesRuby[] = { - { "char", 0, "char", true, true, false, CHAR_MIN, CHAR_MAX, 1 }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 4 }, + { "char", 0, "char", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, }; HostType hostTypesCSharp[] = { - { "sbyte", 0, "sbyte", true, true, false, CHAR_MIN, CHAR_MAX, 1 }, - { "byte", 0, "byte", false, true, false, 0, UCHAR_MAX, 1 }, - { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 2 }, - { "ushort", 0, "ushort", false, true, false, 0, USHRT_MAX, 2 }, - { "char", 0, "char", false, true, true, 0, USHRT_MAX, 2 }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 4 }, - { "uint", 0, "uint", false, true, false, 0, UINT_MAX, 4 }, - { "long", 0, "long", true, true, false, LONG_MIN, LONG_MAX, 8 }, - { "ulong", 0, "ulong", false, true, false, 0, ULONG_MAX, 8 } + { "sbyte", 0, "sbyte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, + { "byte", 0, "byte", false, true, false, 0, 0, 0, UCHAR_MAX, 1 }, + { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 }, + { "ushort", 0, "ushort", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, + { "char", 0, "char", false, true, true, 0, 0, 0, USHRT_MAX, 2 }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, + { "uint", 0, "uint", false, true, false, 0, 0, 0, UINT_MAX, 4 }, + { "long", 0, "long", true, true, false, LONG_MIN, LONG_MAX, 0, 0, 8 }, + { "ulong", 0, "ulong", false, true, false, 0, 0, 0, ULONG_MAX, 8 } }; HostType hostTypesOCaml[] = { -// { "char", 0, "char", false, true, false, 0, UCHAR_MAX, 1 }, - { "int", 0, "int", true, true, false, S31BIT_MIN, S31BIT_MAX, 4 }, + { "int", 0, "int", true, true, false, S31BIT_MIN, S31BIT_MAX, 0, 0, 4 }, }; HostLang hostLangC = { HostLang::C, hostTypesC, 8, hostTypesC+0, true }; diff --git a/ragel/common.h b/ragel/common.h index b26da68..3ee71d2 100644 --- a/ragel/common.h +++ b/ragel/common.h @@ -116,8 +116,10 @@ struct HostType bool isSigned; bool isOrd; bool isChar; - long long minVal; - long long maxVal; + long long sMinVal; + long long sMaxVal; + unsigned long long uMinVal; + unsigned long long uMaxVal; unsigned int size; }; @@ -174,12 +176,12 @@ struct KeyOps this->alphType = alphType; isSigned = alphType->isSigned; if ( isSigned ) { - minKey = (long) alphType->minVal; - maxKey = (long) alphType->maxVal; + minKey = (long) alphType->sMinVal; + maxKey = (long) alphType->sMaxVal; } else { - minKey = (long) (unsigned long) alphType->minVal; - maxKey = (long) (unsigned long) alphType->maxVal; + minKey = (long) (unsigned long) alphType->uMinVal; + maxKey = (long) (unsigned long) alphType->uMaxVal; } } @@ -200,18 +202,25 @@ struct KeyOps HostType *typeSubsumes( long long maxVal ) { + HostType *hostTypes = hostLang->hostTypes; + for ( int i = 0; i < hostLang->numHostTypes; i++ ) { - if ( maxVal <= hostLang->hostTypes[i].maxVal ) - return hostLang->hostTypes + i; + long long typeMaxVal = hostTypes[i].isSigned ? hostTypes[i].sMaxVal : hostTypes[i].uMaxVal; + if ( maxVal <= typeMaxVal ) + return &hostLang->hostTypes[i]; } + return 0; } HostType *typeSubsumes( bool isSigned, long long maxVal ) { + HostType *hostTypes = hostLang->hostTypes; + for ( int i = 0; i < hostLang->numHostTypes; i++ ) { - if ( ( ( isSigned && hostLang->hostTypes[i].isSigned ) || !isSigned ) && - maxVal <= hostLang->hostTypes[i].maxVal ) + long long typeMaxVal = hostTypes[i].isSigned ? hostTypes[i].sMaxVal : hostTypes[i].uMaxVal; + if ( ( ( isSigned && hostTypes[i].isSigned ) || !isSigned ) && + maxVal <= typeMaxVal ) return hostLang->hostTypes + i; } return 0; diff --git a/ragel/config.h.in b/ragel/config.h.in index 2dd9bdb..79d8e9c 100644 --- a/ragel/config.h.in +++ b/ragel/config.h.in @@ -1,4 +1,4 @@ -/* ragel/config.h.in. Generated from configure.in by autoheader. */ +/* ragel/config.h.in. Generated from configure.ac by autoheader. */ /* Name of package */ #undef PACKAGE diff --git a/ragel/cscodegen.cpp b/ragel/cscodegen.cpp index 6de1506..37eb521 100644 --- a/ragel/cscodegen.cpp +++ b/ragel/cscodegen.cpp @@ -635,7 +635,7 @@ void CSharpFsmCodeGen::STATE_IDS() out << "\n"; - if ( 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"; diff --git a/ragel/cstable.cpp b/ragel/cstable.cpp index 72df0a6..13c9e73 100644 --- a/ragel/cstable.cpp +++ b/ragel/cstable.cpp @@ -618,15 +618,22 @@ std::ostream &CSharpTabCodeGen::TRANS_ACTIONS_WI() void CSharpTabCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) { - ret << "{" << vCS() << " = " << gotoDest << "; " << - CTRL_FLOW() << "goto _again;}"; + ret << "{" << vCS() << " = " << gotoDest << ";"; + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void CSharpTabCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) { ret << "{" << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish ); - ret << "); " << CTRL_FLOW() << "goto _again;}"; + ret << ");"; + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void CSharpTabCodeGen::CURS( ostream &ret, bool inFinish ) @@ -658,8 +665,13 @@ void CSharpTabCodeGen::CALL( ostream &ret, int callDest, int targState, bool inF INLINE_LIST( ret, prePushExpr, 0, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << - callDest << "; " << CTRL_FLOW() << "goto _again;}"; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; if ( prePushExpr != 0 ) ret << "}"; @@ -672,9 +684,15 @@ void CSharpTabCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targS INLINE_LIST( ret, prePushExpr, 0, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, targState, inFinish ); - ret << "); " << CTRL_FLOW() << "goto _again;}"; + ret << ");"; + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; if ( prePushExpr != 0 ) ret << "}"; @@ -682,8 +700,9 @@ void CSharpTabCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targS void CSharpTabCodeGen::RET( ostream &ret, bool inFinish ) { - ret << "{" << vCS() << " = " << STACK() << "[--" << - TOP() << "]; "; + ret << "{"; + + ret << vCS() << " = " << STACK() << "[--" << TOP() << "]; "; if ( postPopExpr != 0 ) { ret << "{"; @@ -691,7 +710,9 @@ void CSharpTabCodeGen::RET( ostream &ret, bool inFinish ) ret << "}"; } - ret << CTRL_FLOW() << "goto _again;}"; + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void CSharpTabCodeGen::BREAK( ostream &ret, int targState ) diff --git a/ragel/fsmgraph.h b/ragel/fsmgraph.h index 1b7d6f5..c7e676b 100644 --- a/ragel/fsmgraph.h +++ b/ragel/fsmgraph.h @@ -859,7 +859,7 @@ template PairIter::Pair #define CO_RETURN(label) \ itState = label; \ return; \ - entry##label: backIn = true + entry##label: {} /* Return and re-entry for the co-routine iterators. This should ALWAYS be * used inside of a block. */ @@ -867,16 +867,12 @@ template PairIter::Pair itState = label; \ userState = uState; \ return; \ - entry##label: backIn = true + entry##label: {} /* Advance to the next transition. When returns, trans points to the next * transition, unless there are no more, in which case end() returns true. */ template void PairIter::findNext() { - /* This variable is used in dummy statements that follow the entry - * goto labels. The compiler needs some statement to follow the label. */ - bool backIn; - /* Jump into the iterator routine base on the iterator state. */ switch ( itState ) { case Begin: goto entryBegin; diff --git a/ragel/gendata.cpp b/ragel/gendata.cpp index 65f0b52..737a53c 100644 --- a/ragel/gendata.cpp +++ b/ragel/gendata.cpp @@ -452,6 +452,7 @@ CodeGenData::CodeGenData( ostream &out ) noPrefix(false), noFinal(false), noError(false), + noEntry(false), noCS(false) {} @@ -837,6 +838,10 @@ void CodeGenData::analyzeAction( GenAction *act, GenInlineList *inlineList ) redFsm->bAnyActionCalls = true; else if ( item->type == GenInlineItem::Ret ) redFsm->bAnyActionRets = true; + + if ( item->type == GenInlineItem::CallExpr || item->type == GenInlineItem::GotoExpr ) + redFsm->bAnyActionByValControl = true; + } /* Check for various things in regular actions. */ @@ -1079,6 +1084,8 @@ bool CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args ) noPrefix = true; else if ( strcmp( args[i], "nofinal" ) == 0 ) noFinal = true; + else if ( strcmp( args[i], "noentry" ) == 0 ) + noEntry = true; else write_option_error( loc, args[i] ); } diff --git a/ragel/gendata.h b/ragel/gendata.h index 071c601..6c3d385 100644 --- a/ragel/gendata.h +++ b/ragel/gendata.h @@ -129,6 +129,7 @@ struct CodeGenData bool noPrefix; bool noFinal; bool noError; + bool noEntry; bool noCS; void createMachine(); diff --git a/ragel/gocodegen.cpp b/ragel/gocodegen.cpp index 5ff44c1..d28f0f0 100644 --- a/ragel/gocodegen.cpp +++ b/ragel/gocodegen.cpp @@ -632,7 +632,7 @@ void GoCodeGen::STATE_IDS() out << endl; - if ( entryPointNames.length() > 0 ) { + if ( !noEntry && entryPointNames.length() > 0 ) { for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) { CONST( "int", DATA_PREFIX() + "en_" + *en ) << " = " << entryPointIds[en.pos()] << endl; diff --git a/ragel/javacodegen.cpp b/ragel/javacodegen.cpp index ff2193c..8cc64f8 100644 --- a/ragel/javacodegen.cpp +++ b/ragel/javacodegen.cpp @@ -984,7 +984,7 @@ void JavaTabCodeGen::writeData() out << "\n"; - if ( 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"; diff --git a/ragel/mlcodegen.cpp b/ragel/mlcodegen.cpp index f8268d6..166e453 100644 --- a/ragel/mlcodegen.cpp +++ b/ragel/mlcodegen.cpp @@ -565,7 +565,7 @@ void OCamlCodeGen::STATE_IDS() out << "\n"; - if ( 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()] << TOP_SEP(); diff --git a/ragel/parsedata.cpp b/ragel/parsedata.cpp index 8ce89db..d0bb361 100644 --- a/ragel/parsedata.cpp +++ b/ragel/parsedata.cpp @@ -122,29 +122,50 @@ Key makeFsmKeyHex( char *str, const InputLoc &loc, ParseData *pd ) Key makeFsmKeyDec( char *str, const InputLoc &loc, ParseData *pd ) { - /* Convert the number to a decimal. First reset errno so we can check - * for overflow or underflow. */ - errno = 0; - long long minVal = keyOps->alphType->minVal; - long long maxVal = keyOps->alphType->maxVal; - - long long ll = strtoll( str, 0, 10 ); - - /* Check for underflow. */ - if ( ( errno == ERANGE && ll < 0 ) || ll < minVal) { - error(loc) << "literal " << str << " underflows the alphabet type" << endl; - ll = minVal; + if ( keyOps->alphType->isSigned ) { + /* Convert the number to a decimal. First reset errno so we can check + * for overflow or underflow. */ + errno = 0; + long long minVal = keyOps->alphType->sMinVal; + long long maxVal = keyOps->alphType->sMaxVal; + + long long ll = strtoll( str, 0, 10 ); + + /* Check for underflow. */ + if ( ( errno == ERANGE && ll < 0 ) || ll < minVal) { + error(loc) << "literal " << str << " underflows the alphabet type" << endl; + ll = minVal; + } + /* Check for overflow. */ + else if ( ( errno == ERANGE && ll > 0 ) || ll > maxVal ) { + error(loc) << "literal " << str << " overflows the alphabet type" << endl; + ll = maxVal; + } + + return Key( (long)ll ); } - /* Check for overflow. */ - else if ( ( errno == ERANGE && ll > 0 ) || ll > maxVal ) { - error(loc) << "literal " << str << " overflows the alphabet type" << endl; - ll = maxVal; + else { + /* Convert the number to a decimal. First reset errno so we can check + * for overflow or underflow. */ + errno = 0; + unsigned long long minVal = keyOps->alphType->uMinVal; + unsigned long long maxVal = keyOps->alphType->uMaxVal; + + unsigned long long ull = strtoull( str, 0, 10 ); + + /* Check for underflow. */ + if ( ( errno == ERANGE && ull < 0 ) || ull < minVal) { + error(loc) << "literal " << str << " underflows the alphabet type" << endl; + ull = minVal; + } + /* Check for overflow. */ + else if ( ( errno == ERANGE && ull > 0 ) || ull > maxVal ) { + error(loc) << "literal " << str << " overflows the alphabet type" << endl; + ull = maxVal; + } + + return Key( (unsigned long)ull ); } - - if ( keyOps->alphType->isSigned ) - return Key( (long)ll ); - else - return Key( (unsigned long)ll ); } /* Make an fsm key in int format (what the fsm graph uses) from an alphabet diff --git a/ragel/parsetree.cpp b/ragel/parsetree.cpp index 3245a54..ff538aa 100644 --- a/ragel/parsetree.cpp +++ b/ragel/parsetree.cpp @@ -583,8 +583,6 @@ Join::Join( const InputLoc &loc, Expression *expr ) /* Construct with a location and the first expression. */ Join::Join( Expression *expr ) -: - loc(loc) { exprList.append( expr ); } diff --git a/ragel/parsetree.h b/ragel/parsetree.h index dd38678..954542e 100644 --- a/ragel/parsetree.h +++ b/ragel/parsetree.h @@ -385,11 +385,11 @@ struct Expression /* Construct with an expression on the left and a term on the right. */ Expression( Expression *expression, Term *term, Type type ) : expression(expression), term(term), - builtin(builtin), type(type), prev(this), next(this) { } + type(type), prev(this), next(this) { } /* Construct with only a term. */ Expression( Term *term ) : - expression(0), term(term), builtin(builtin), + expression(0), term(term), type(TermType) , prev(this), next(this) { } /* Construct with a builtin type. */ diff --git a/ragel/rbxgoto.cpp b/ragel/rbxgoto.cpp index c54cb00..932fdf3 100644 --- a/ragel/rbxgoto.cpp +++ b/ragel/rbxgoto.cpp @@ -658,7 +658,7 @@ void RbxGotoCodeGen::BREAK( ostream &ret, int targState ) out << " begin\n" " " << P() << " += 1\n" - " " << rbxGoto(ret, "_out") << "\n" + " "; rbxGoto(ret, "_out") << "\n" " end\n"; } diff --git a/ragel/redfsm.cpp b/ragel/redfsm.cpp index 9a58752..5b02d99 100644 --- a/ragel/redfsm.cpp +++ b/ragel/redfsm.cpp @@ -56,6 +56,7 @@ RedFsmAp::RedFsmAp() bAnyActionGotos(false), bAnyActionCalls(false), bAnyActionRets(false), + bAnyActionByValControl(false), bAnyRegActionRets(false), bAnyRegActionByValControl(false), bAnyRegNextStmt(false), diff --git a/ragel/redfsm.h b/ragel/redfsm.h index 2e7ad7c..badca23 100644 --- a/ragel/redfsm.h +++ b/ragel/redfsm.h @@ -421,6 +421,7 @@ struct RedFsmAp bool bAnyActionGotos; bool bAnyActionCalls; bool bAnyActionRets; + bool bAnyActionByValControl; bool bAnyRegActionRets; bool bAnyRegActionByValControl; bool bAnyRegNextStmt; @@ -456,6 +457,7 @@ struct RedFsmAp bool anyActionGotos() { return bAnyActionGotos; } bool anyActionCalls() { return bAnyActionCalls; } bool anyActionRets() { return bAnyActionRets; } + bool anyActionByValControl() { return bAnyActionByValControl; } bool anyRegActionRets() { return bAnyRegActionRets; } bool anyRegActionByValControl() { return bAnyRegActionByValControl; } bool anyRegNextStmt() { return bAnyRegNextStmt; } diff --git a/ragel/rubycodegen.cpp b/ragel/rubycodegen.cpp index ff25ada..ee68238 100644 --- a/ragel/rubycodegen.cpp +++ b/ragel/rubycodegen.cpp @@ -430,7 +430,7 @@ void RubyCodeGen::STATE_IDS() out << "\n"; - if ( 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"; diff --git a/ragel/version.h b/ragel/version.h index 87d9750..3b1233c 100644 --- a/ragel/version.h +++ b/ragel/version.h @@ -1,2 +1,2 @@ -#define VERSION "6.9" -#define PUBDATE "Oct 2014" +#define VERSION "6.10" +#define PUBDATE "March 2017" -- cgit v1.2.1