@@ -593,7 +593,7 @@ bool ps_visit_type_reference_subrange(ps_interpreter *interpreter, ps_interprete
593593}
594594
595595/**
596- * 'ARRAY' '[' SUBRANGE | IDENTIFIER ']' 'OF' TYPE_REFERENCE
596+ * 'ARRAY' '[' SUBRANGE | IDENTIFIER [ ',' SUBRANGE | IDENTIFIER ]* ']' 'OF' TYPE_REFERENCE
597597 */
598598bool ps_visit_type_reference_array (ps_interpreter * interpreter , ps_interpreter_mode mode , ps_symbol * * type_symbol ,
599599 const char * type_name )
@@ -615,7 +615,7 @@ bool ps_visit_type_reference_array(ps_interpreter *interpreter, ps_interpreter_m
615615 READ_NEXT_TOKEN
616616 do
617617 {
618- // SUBRANGE ( LOW '..' HIGH)
618+ // SUBRANGE: LOW '..' HIGH | IDENTIFIER
619619 if (!ps_visit_type_reference (interpreter , mode , & subrange , NULL ))
620620 TRACE_ERROR ("DIMENSION" )
621621 // Dimension *must* be a subrange
@@ -628,14 +628,17 @@ bool ps_visit_type_reference_array(ps_interpreter *interpreter, ps_interpreter_m
628628 {
629629 if (dimensions == 8 )
630630 RETURN_ERROR (PS_ERROR_TOO_MANY_DIMENSIONS )
631+ READ_NEXT_TOKEN
631632 continue ;
632633 }
633634 // ']'
634635 if (lexer -> current_token .type == PS_TOKEN_RIGHT_BRACKET )
636+ {
637+ READ_NEXT_TOKEN
635638 break ;
639+ }
636640 RETURN_ERROR (PS_ERROR_UNEXPECTED_TOKEN )
637641 } while (true);
638- READ_NEXT_TOKEN
639642 // 'OF'
640643 if (lexer -> current_token .type != PS_TOKEN_OF )
641644 RETURN_ERROR (PS_ERROR_UNEXPECTED_TOKEN )
@@ -644,7 +647,11 @@ bool ps_visit_type_reference_array(ps_interpreter *interpreter, ps_interpreter_m
644647 if (!ps_visit_type_reference (interpreter , mode , & item_type , NULL ))
645648 TRACE_ERROR ("ITEM_TYPE ")
646649 // Item type can be any type, even another array
647-
650+ if (item_type - > kind != PS_SYMBOL_KIND_TYPE_DEFINITION )
651+ RETURN_ERROR (PS_ERROR_EXPECTED_TYPE )
652+ // For now, item_type cannot be an array type
653+ if (item_type - > value - > data .t - > type == PS_TYPE_ARRAY )
654+ RETURN_ERROR (PS_ERROR_NOT_IMPLEMENTED )
648655 // Create type definition for array
649656 ps_type_definition * type_def = NULL ;
650657 ps_identifier name = {0 };
@@ -661,11 +668,12 @@ bool ps_visit_type_reference_array(ps_interpreter *interpreter, ps_interpreter_m
661668 ps_type_definition_free (type_def );
662669 RETURN_ERROR (PS_ERROR_OUT_OF_MEMORY );
663670 }
664- for (int i = 0 ; i <= dimensions ; i ++ ) {
671+ for (int i = 0 ; i <= dimensions ; i ++ )
672+ {
665673 type_def -> def .a .subranges [i ] = subranges [i ];
666674 }
667- type_def -> def .a .item_type = item_type ;
668675 type_def -> def .a .dimensions = dimensions ;
676+ type_def -> def .a .item_type = item_type ;
669677 // Register new type definition in symbol table
670678 if (!ps_type_definition_register (interpreter , mode , name , type_def , type_symbol ))
671679 RETURN_ERROR (interpreter -> error )
0 commit comments