From ccbbcaafd90c2045f5bf9a1381a9d2affd9aeeb9 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Sun, 18 Jan 2015 14:12:16 +0000 Subject: [PATCH] Replaced "YYHAS (n)" with "YYEOI (n)". The actual meaning of this primitive is to check if there's not enough characters left in the input stream, e.g. "(YYLIMIT - YYCURSOR) < n" or whatever else. --- re2c/code.cc | 6 +++--- re2c/input_api.cc | 8 ++++---- re2c/input_api.h | 4 ++-- re2c/test/input_custom_default.--input(custom).c | 6 +++--- re2c/test/input_custom_default.--input(custom).re | 2 +- re2c/test/input_custom_fgetc.--input(custom).c | 6 +++--- re2c/test/input_custom_fgetc.--input(custom).re | 2 +- re2c/test/input_custom_istringstream.--input(custom).c | 6 +++--- re2c/test/input_custom_istringstream.--input(custom).re | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/re2c/code.cc b/re2c/code.cc index f548bab1..52b28efc 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -408,7 +408,7 @@ static void need(std::ostream &o, uint ind, uint n, bool & readCh, bool bSetMark { if (bUseYYFillCheck) { - o << "if (" << input_api.expr_has_one () << ") "; + o << "if (" << input_api.expr_eoi_one () << ") "; } genYYFill(o, ind, n); } @@ -416,7 +416,7 @@ static void need(std::ostream &o, uint ind, uint n, bool & readCh, bool bSetMark { if (bUseYYFillCheck) { - o << "if (" << input_api.expr_has (n) << ") "; + o << "if (" << input_api.expr_eoi (n) << ") "; } genYYFill(o, ind, n); } @@ -2318,7 +2318,7 @@ void Scanner::config(const Str& cfg, const Str& val) mapDefineKeys.insert("define:YYFILL"); mapDefineKeys.insert("define:YYGETCONDITION"); mapDefineKeys.insert("define:YYGETSTATE"); - mapDefineKeys.insert("define:YYHAS"); + mapDefineKeys.insert("define:YYEOI"); mapDefineKeys.insert("define:YYLIMIT"); mapDefineKeys.insert("define:YYMARKER"); mapDefineKeys.insert("define:YYPEEK"); diff --git a/re2c/input_api.cc b/re2c/input_api.cc index 497e8569..0053f216 100644 --- a/re2c/input_api.cc +++ b/re2c/input_api.cc @@ -142,14 +142,14 @@ std::string InputAPI::stmt_skip_backup_peek (uint ind) : stmt_skip (ind) + stmt_backup (ind) + stmt_peek (ind); } -std::string InputAPI::expr_has_one () +std::string InputAPI::expr_eoi_one () { return type == DEFAULT ? mapCodeName["YYLIMIT"] + " <= " + mapCodeName["YYCURSOR"] - : expr_has (1); + : expr_eoi (1); } -std::string InputAPI::expr_has (uint n) +std::string InputAPI::expr_eoi (uint n) { std::ostringstream s; switch (type) @@ -158,7 +158,7 @@ std::string InputAPI::expr_has (uint n) s << "(" << mapCodeName["YYLIMIT"] << " - " << mapCodeName["YYCURSOR"] << ") < " << n; break; case CUSTOM: - s << mapCodeName["YYHAS"] << " (" << n << ")"; + s << mapCodeName["YYEOI"] << " (" << n << ")"; break; } return s.str (); diff --git a/re2c/input_api.h b/re2c/input_api.h index 974194fb..428f5b4a 100644 --- a/re2c/input_api.h +++ b/re2c/input_api.h @@ -34,8 +34,8 @@ public: std::string stmt_skip_backup (uint ind); std::string stmt_backup_peek (uint ind); std::string stmt_skip_backup_peek (uint ind); - std::string expr_has_one (); - std::string expr_has (uint n); + std::string expr_eoi_one (); + std::string expr_eoi (uint n); }; } // end namespace re2c diff --git a/re2c/test/input_custom_default.--input(custom).c b/re2c/test/input_custom_default.--input(custom).c index 7e31b807..fb6e2755 100644 --- a/re2c/test/input_custom_default.--input(custom).c +++ b/re2c/test/input_custom_default.--input(custom).c @@ -11,14 +11,14 @@ bool lex (const char * cursor, const char * const limit) # define YYBACKUPCTX() ctxmarker = cursor # define YYRESTORE() cursor = marker # define YYRESTORECTX() cursor = ctxmarker -# define YYHAS(n) limit - cursor < n +# define YYEOI(n) limit - cursor < n # define YYFILL(n) {} #line 18 "" { YYCTYPE yych; - if (YYHAS (13)) YYFILL(13); + if (YYEOI (13)) YYFILL(13); yych = YYPEEK (); switch (yych) { case 'i': goto yy4; @@ -130,7 +130,7 @@ yy16: } yy17: YYSKIP (); - if (YYHAS (1)) YYFILL(1); + if (YYEOI (1)) YYFILL(1); yych = YYPEEK (); switch (yych) { case '0': diff --git a/re2c/test/input_custom_default.--input(custom).re b/re2c/test/input_custom_default.--input(custom).re index 933d7666..90781642 100644 --- a/re2c/test/input_custom_default.--input(custom).re +++ b/re2c/test/input_custom_default.--input(custom).re @@ -9,7 +9,7 @@ bool lex (const char * cursor, const char * const limit) # define YYBACKUPCTX() ctxmarker = cursor # define YYRESTORE() cursor = marker # define YYRESTORECTX() cursor = ctxmarker -# define YYHAS(n) limit - cursor < n +# define YYEOI(n) limit - cursor < n # define YYFILL(n) {} /*!re2c "int buffer " / "[" [0-9]+ "]" { return true; } diff --git a/re2c/test/input_custom_fgetc.--input(custom).c b/re2c/test/input_custom_fgetc.--input(custom).c index 9e043915..e9ce4b0d 100644 --- a/re2c/test/input_custom_fgetc.--input(custom).c +++ b/re2c/test/input_custom_fgetc.--input(custom).c @@ -20,14 +20,14 @@ bool lex (FILE * f, const long limit) # define YYBACKUPCTX() ctxmarker = ftell (f) # define YYRESTORE() fseek (f, marker, SEEK_SET) # define YYRESTORECTX() fseek (f, ctxmarker, SEEK_SET) -# define YYHAS(n) limit - ftell (f) < n +# define YYEOI(n) limit - ftell (f) < n # define YYFILL(n) {} #line 27 "" { YYCTYPE yych; - if (YYHAS (13)) YYFILL(13); + if (YYEOI (13)) YYFILL(13); yych = YYPEEK (); switch (yych) { case 'i': goto yy4; @@ -139,7 +139,7 @@ yy16: } yy17: YYSKIP (); - if (YYHAS (1)) YYFILL(1); + if (YYEOI (1)) YYFILL(1); yych = YYPEEK (); switch (yych) { case '0': diff --git a/re2c/test/input_custom_fgetc.--input(custom).re b/re2c/test/input_custom_fgetc.--input(custom).re index 3116479a..b6c3ef1d 100644 --- a/re2c/test/input_custom_fgetc.--input(custom).re +++ b/re2c/test/input_custom_fgetc.--input(custom).re @@ -18,7 +18,7 @@ bool lex (FILE * f, const long limit) # define YYBACKUPCTX() ctxmarker = ftell (f) # define YYRESTORE() fseek (f, marker, SEEK_SET) # define YYRESTORECTX() fseek (f, ctxmarker, SEEK_SET) -# define YYHAS(n) limit - ftell (f) < n +# define YYEOI(n) limit - ftell (f) < n # define YYFILL(n) {} /*!re2c "int buffer " / "[" [0-9]+ "]" { return true; } diff --git a/re2c/test/input_custom_istringstream.--input(custom).c b/re2c/test/input_custom_istringstream.--input(custom).c index d40a354c..0bf59a3d 100644 --- a/re2c/test/input_custom_istringstream.--input(custom).c +++ b/re2c/test/input_custom_istringstream.--input(custom).c @@ -13,14 +13,14 @@ bool lex (std::istringstream & is, const std::streampos limit) # define YYBACKUPCTX() ctxmarker = is.tellg () # define YYRESTORE() is.seekg (marker) # define YYRESTORECTX() is.seekg (ctxmarker) -# define YYHAS(n) limit - is.tellg () < n +# define YYEOI(n) limit - is.tellg () < n # define YYFILL(n) {} #line 20 "" { YYCTYPE yych; - if (YYHAS (13)) YYFILL(13); + if (YYEOI (13)) YYFILL(13); yych = YYPEEK (); switch (yych) { case 'i': goto yy4; @@ -132,7 +132,7 @@ yy16: } yy17: YYSKIP (); - if (YYHAS (1)) YYFILL(1); + if (YYEOI (1)) YYFILL(1); yych = YYPEEK (); switch (yych) { case '0': diff --git a/re2c/test/input_custom_istringstream.--input(custom).re b/re2c/test/input_custom_istringstream.--input(custom).re index 76197a2e..35f4b002 100644 --- a/re2c/test/input_custom_istringstream.--input(custom).re +++ b/re2c/test/input_custom_istringstream.--input(custom).re @@ -11,7 +11,7 @@ bool lex (std::istringstream & is, const std::streampos limit) # define YYBACKUPCTX() ctxmarker = is.tellg () # define YYRESTORE() is.seekg (marker) # define YYRESTORECTX() is.seekg (ctxmarker) -# define YYHAS(n) limit - is.tellg () < n +# define YYEOI(n) limit - is.tellg () < n # define YYFILL(n) {} /*!re2c "int buffer " / "[" [0-9]+ "]" { return true; } -- 2.40.0