Skip to content

Commit 99ce66a

Browse files
committed
[parser] Eliminate loop from Parse_Directive().
1 parent f0b7ee2 commit 99ce66a

File tree

3 files changed

+180
-216
lines changed

3 files changed

+180
-216
lines changed

source/parser/parser.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7073,27 +7073,24 @@ void Parser::Parse_Frame ()
70737073
END_CASE
70747074

70757075
CASE (DECLARE_TOKEN)
7076-
UNGET
70777076
VersionWarning(295,"Should have '#' before 'declare'.");
70787077
POV_EXPERIMENTAL_ASSERT(IsOkToDeclare());
7079-
Parse_Directive (false);
7078+
Parse_Declare(false, false);
70807079
END_CASE
70817080

70827081
CASE (INCLUDE_TOKEN)
7083-
UNGET
70847082
VersionWarning(295,"Should have '#' before 'include'.");
70857083
POV_EXPERIMENTAL_ASSERT(IsOkToDeclare());
7086-
Parse_Directive (false);
7084+
Open_Include();
70877085
END_CASE
70887086

70897087
CASE (FLOAT_FUNCT_TOKEN)
70907088
switch(CurrentTokenFunctionId())
70917089
{
70927090
case VERSION_TOKEN:
7093-
UNGET
70947091
VersionWarning(295,"Should have '#' before 'version'.");
70957092
POV_EXPERIMENTAL_ASSERT(IsOkToDeclare());
7096-
Parse_Directive (false);
7093+
Parse_Version();
70977094
break;
70987095

70997096
default:
@@ -9220,8 +9217,12 @@ bool Parser::Parse_RValue (TokenId Previous, TokenId *NumberPtr, void **DataPtr,
92209217
Terms = Parse_Unknown_Vector (Local_Express, true, &had_callable_identifier);
92219218

92229219
// if in a #declare force a semicolon at the end
9220+
// (but don't "eat" it yet, `Parse_Declare` will take care of that)
92239221
if (SemiFlag)
9222+
{
92249223
Parse_Semi_Colon(true);
9224+
UNGET
9225+
}
92259226

92269227
// get the number of tokens found
92279228
Temp_Count = mTokenCount - Temp_Count;

source/parser/parser.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ class Parser
240240
TokenId *NumberPtr;
241241
void **DataPtr;
242242
SymbolTable* table; ///< table or dictionary the token references an element of
243-
bool Unget_Token : 1; ///< `true` if @ref Get_Token() must re-issue this token.
243+
bool Unget_Token : 1; ///< `true` if @ref Get_Token() must re-issue this token as-is.
244+
bool ungetRaw : 1; ///< `true` if @ref Get_Token() must re-evaluate this token from raw.
244245
bool End_Of_File : 1;
245246
bool is_array_elem : 1; ///< true if token is actually an array element reference
246247
bool is_mixed_array_elem : 1; ///< true if token is actually a mixed-type array element reference
@@ -475,10 +476,11 @@ class Parser
475476
bool GoToBookmark(const RawTokenizer::HotBookmark& bookmark);
476477

477478
bool IsEndOfInvokedMacro() const;
478-
void Parse_Directive (int After_Hash);
479+
void Parse_Directive();
479480
#if POV_DEBUG
480481
void Parse_Breakpoint();
481482
#endif
483+
void Parse_Version();
482484
void Open_Include (void);
483485
void IncludeHeader(const UCS2String& temp);
484486
void pre_init_tokenizer (void);

0 commit comments

Comments
 (0)