FROM M2Base IMPORT IsParameterCompatible, IsAssignmentCompatible, IsExpressionCompatible, IsComparisonCompatible, IsBaseType, IsMathType, ZType, CType, RType, IsComplexType, Char ;
FROM Indexing IMPORT Index, InitIndex, GetIndice, PutIndice, KillIndex, HighIndice, LowIndice, IncludeIndiceIntoIndex, ForeachIndiceInIndexDo ;
FROM M2Error IMPORT Error, InternalError, NewError, ErrorString, ChainError ;
-FROM M2MetaError IMPORT MetaErrorStringT2, MetaErrorStringT3, MetaErrorStringT4, MetaString2, MetaString3, MetaString4 ;
+FROM M2MetaError IMPORT MetaErrorStringT2, MetaErrorStringT3, MetaErrorStringT4, MetaString2, MetaString3, MetaString4, MetaError1 ;
FROM StrLib IMPORT StrEqual ;
FROM M2Debug IMPORT Assert ;
(* and also generate a sub error containing detail. *)
IF (left # tinfo^.left) OR (right # tinfo^.right)
THEN
- tinfo^.error := ChainError (tinfo^.token, tinfo^.error) ;
- s := MetaString2 (InitString ("{%1Ead} and {%2ad} are incompatible as formal and actual procedure parameters"),
- left, right) ;
- ErrorString (tinfo^.error, s)
+ MetaError1 ('formal parameter {%1EDad}', right) ;
+ MetaError1 ('actual parameter {%1EDad}', left)
END
END
END buildError4 ;
IMPLEMENTATION MODULE P2Build ;
-FROM M2LexBuf IMPORT currentstring, currenttoken, GetToken, InsertToken, InsertTokenAndRewind, GetTokenNo ;
+FROM M2LexBuf IMPORT currentstring, currenttoken, GetToken, InsertToken,
+ InsertTokenAndRewind, GetTokenNo, MakeVirtual2Tok ;
+
FROM M2MetaError IMPORT MetaErrorStringT0, MetaErrorT1 ;
FROM NameKey IMPORT NulName, Name, makekey, MakeKey ;
FROM M2Reserved IMPORT tokToTok, toktype, NulTok, ImportTok, ExportTok, QualifiedTok, UnQualifiedTok ;
END %
=:
-SubrangeType := "[" ConstExpression ".." ConstExpression "]" % BuildSubrange(NulSym) %
+SubrangeType := % VAR start, combined: CARDINAL ; %
+ % start := GetTokenNo () %
+ "[" ConstExpression ".." ConstExpression "]" % combined := MakeVirtual2Tok (start, GetTokenNo ()-1) %
+ % BuildSubrange (combined, NulSym) %
=:
-PrefixedSubrangeType := "[" ConstExpression ".." ConstExpression "]" % VAR t: CARDINAL ; %
- % PopT(t) ;
- BuildSubrange(t) %
+PrefixedSubrangeType := % VAR qual, start, combined: CARDINAL ; %
+ % PopTtok (qual, start) %
+ "[" ConstExpression ".." ConstExpression "]"
+ % combined := MakeVirtual2Tok (start, GetTokenNo ()-1) %
+ % BuildSubrange (combined, qual) %
=:
ArrayType := "ARRAY" % VAR arrayType, tok: CARDINAL ; %
|------------| |------------|
*)
-PROCEDURE BuildSubrange (Base: CARDINAL) ;
+PROCEDURE BuildSubrange (tok: CARDINAL; Base: CARDINAL) ;
(*
|------------| |------------|
*)
-PROCEDURE BuildSubrange (Base: CARDINAL) ;
+PROCEDURE BuildSubrange (tok: CARDINAL; Base: CARDINAL) ;
VAR
name: Name ;
Type: CARDINAL ;
- tok : CARDINAL ;
BEGIN
- PopTtok(name, tok) ;
- Type := MakeSubrange(tok, name) ;
+ PopT (name) ;
+ Type := MakeSubrange (tok, name) ;
PutSubrangeIntoFifoQueue(Type) ; (* Store Subrange away so that we can fill in *)
(* its bounds during pass 3. *)
PutSubrangeIntoFifoQueue(Base) ; (* store Base type of subrange away as well. *)
--- /dev/null
+MODULE badbecomes2 ;
+
+TYPE
+ enums = (red, blue, green) ;
+VAR
+ setvar: SET OF enums ;
+BEGIN
+ setvar := green ; (* Should detect an error here. *)
+END badbecomes2.
--- /dev/null
+MODULE badparamset1 ;
+
+TYPE
+ month = SET OF [1..12] ;
+ day = SET OF [1..31] ;
+
+
+PROCEDURE foo (d: day) ;
+BEGIN
+END foo ;
+
+VAR
+ m: month ;
+BEGIN
+ foo (m)
+END badparamset1.
--- /dev/null
+MODULE badparamset2 ;
+
+TYPE
+ month = SET OF [1..12] ;
+ day = SET OF [1..31] ;
+
+
+PROCEDURE foo (d: day) ;
+BEGIN
+END foo ;
+
+VAR
+ m: month ;
+BEGIN
+ foo (m)
+END badparamset2.
--- /dev/null
+MODULE badsyntaxset1 ;
+
+TYPE
+ foo = SET OF [cat..dog] ;
+
+BEGIN
+
+END badsyntaxset1.