Hi,
I have a situation where a recursive datatype has a number of declarations, including type constructors. Yet when I try to use those same constructors for further declaration within the datatype, the compiler does not recognize them. Yet top-level recognizes them.
I am using PolyML for a rapid prototyping environment. I suspect a problem with PolyML 4.13, but probably I have blundered. Below is a snippet of the code which displays the behavior, which is also shown.
The compiler does not have a problem with "NUM," but has problems with "LBRACKET" and "LBRACKET," when declaring type "lbr_num_rbr_o." Note that top-level recognizes the constructors in question, after the compiler fails.
I always start the compiler fresh after each error.
Best Regards,
Byron
Simplified code:
datatype type_specifierK = INT | VOID and relopK = LE | LT | GT | GE | EQ | NE and addopK = PLUS | MINUS and mulopK = TIMES | OVER and arithopK = addopK | mulopK and tokenK = ENDFILE | ERROR | ELSE | IF | RETURN | WHILE | ID | NUM | ASSIGN | SEMI | COMMA | LPAREN | RPAREN | LBRACKET | RBRACKET | LCURLY | RCURLY | arithopK | relopK | type_specifierK withtype lbr_num_rbr_o = (LBRACKET * NUM * RBRACKET) option ;
Upon loading the above into PolyML 4.13, the following results are obtained:
datatype type_specifierK = INT | VOID
and relopK = LE | LT |GT | GE | EQ | NE and addopK = PLUS | MINUS and mulopK = TIMES | OVER and arithopK = addopK | mulopK and tokenK = ENDFILE | ERROR | ELSE | IF | RETURN | WHILE | ID | NUM | ASSIGN | SEMI | COMMA | LPAREN | RPAREN | LBRACKET | RBRACKET | LCURLY |RCURLY | arithopK | relopK| type_specifierK withtype lbr_num_rbr_o = (LBRACKET * NUM * RBRACKET) option ; # # # # # # # # # # # Error: Type constructor (RBRACKET) has not been declared Found near datatype type_specifierK = INT | VOID and relopK = LE | LT | GT | ... and addopK = PLUS | MINUS and mulopK = TIMES | ... and arithopK = ... and ... withtype lbr_num_rbr_o = (LBRACKET * NUM * RBRACKET) option
Error: Type constructor (LBRACKET) has not been declared Found near datatype type_specifierK = INT | VOID and relopK = LE | LT | GT | ... and addopK = PLUS | MINUS and mulopK = TIMES | ... and arithopK = ... and ... withtype lbr_num_rbr_o = (LBRACKET * NUM * RBRACKET) option
Static errors (pass2)
;
NUM;
val it = NUM : tokenK
LBRACKET;
val it = LBRACKET : tokenK
RBRACKET;
val it = RBRACKET : tokenK
Please let me know your conclusions.
Thanks,
Byron Hale