Skip to content

Commit 535bac5

Browse files
committed
Implement dictionary initializers.
1 parent 5039065 commit 535bac5

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

source/base/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#define OFFICIAL_VERSION_STRING "3.7.1"
4646
#define OFFICIAL_VERSION_NUMBER 371
4747

48-
#define POV_RAY_PRERELEASE "x.dictionary.8790760"
48+
#define POV_RAY_PRERELEASE "x.dictionary.8790824"
4949

5050
#if (POV_RAY_IS_AUTOBUILD == 1) && ((POV_RAY_IS_OFFICIAL == 1) || (POV_RAY_IS_SEMI_OFFICIAL == 1))
5151
#ifdef POV_RAY_PRERELEASE

source/parser/parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9425,7 +9425,7 @@ bool Parser::Parse_RValue (int Previous, int *NumberPtr, void **DataPtr, SYM_ENT
94259425
END_CASE
94269426

94279427
CASE (DICTIONARY_TOKEN)
9428-
Temp_Data = reinterpret_cast<void *>(Create_Sym_Table (true));
9428+
Temp_Data = reinterpret_cast<void *>(Parse_Dictionary_Declare());
94299429
*NumberPtr = DICTIONARY_ID_TOKEN;
94309430
Test_Redefine (Previous,NumberPtr,*DataPtr, allow_redefine);
94319431
*DataPtr = Temp_Data;

source/parser/parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ class Parser : public SceneTask
377377
SYM_ENTRY *Add_Symbol (SYM_TABLE *table, const char *Name,TOKEN Number);
378378
SYM_ENTRY *Add_Symbol (int Index,const char *Name,TOKEN Number);
379379
POV_ARRAY *Parse_Array_Declare (void);
380+
SYM_TABLE *Parse_Dictionary_Declare();
380381
SYM_ENTRY *Create_Entry (const char *Name, TOKEN Number, bool copyName);
381382
SYM_ENTRY *Copy_Entry (const SYM_ENTRY *);
382383
void Acquire_Entry_Reference (SYM_ENTRY *Entry);

source/parser/parser_tokenizer.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3579,6 +3579,50 @@ Parser::POV_ARRAY *Parser::Parse_Array_Declare (void)
35793579

35803580
};
35813581

3582+
3583+
Parser::SYM_TABLE *Parser::Parse_Dictionary_Declare()
3584+
{
3585+
SYM_TABLE *newDictionary;
3586+
SYM_ENTRY *newEntry;
3587+
bool oldParseRawIdentifiers;
3588+
3589+
newDictionary = Create_Sym_Table (true);
3590+
3591+
// TODO REVIEW - maybe we need `Ok_To_Declare = false`?
3592+
3593+
if (!Parse_Begin (false))
3594+
return newDictionary;
3595+
3596+
EXPECT
3597+
CASE (PERIOD_TOKEN)
3598+
oldParseRawIdentifiers = parseRawIdentifiers;
3599+
parseRawIdentifiers = true;
3600+
Get_Token();
3601+
parseRawIdentifiers = oldParseRawIdentifiers;
3602+
if (Token.Token_Id != IDENTIFIER_TOKEN)
3603+
Expectation_Error ("dictionary element identifier");
3604+
newEntry = Add_Symbol (newDictionary, Token.Token_String, IDENTIFIER_TOKEN);
3605+
3606+
GET (EQUALS_TOKEN);
3607+
3608+
if (!Parse_RValue (IDENTIFIER_TOKEN, &(newEntry->Token_Number), &(newEntry->Data), newEntry, false, false, true, true, false, MAX_NUMBER_OF_TABLES))
3609+
Expectation_Error("RValue");
3610+
3611+
Parse_Comma();
3612+
END_CASE
3613+
3614+
OTHERWISE
3615+
UNGET
3616+
EXIT
3617+
END_CASE
3618+
END_EXPECT
3619+
3620+
Parse_End();
3621+
3622+
return newDictionary;
3623+
3624+
};
3625+
35823626
void Parser::Parse_Initalizer (int Sub, int Base, POV_ARRAY *a)
35833627
{
35843628
int i;

unix/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7.1-x.dictionary.8790760
1+
3.7.1-x.dictionary.8790824

0 commit comments

Comments
 (0)