Re: ML-Yacc generated code error
John Reppy <[email protected]> Sun, 25 Jan 2009 11:57:15 -0600
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
Your problem is that the types stm and exp are defined in the Absyn structure. You need to refer to them as A.stm and A.exp. - John On Jan 25, 2009, at 11:22 AM, Boris D wrote: > Hi, > I'm trying to compile the parser for the straight-line language from > the book "Modern Compiler Implementation in ML" (p.96). ML-Yacc > processes the grammar file without problems, but the generated ML > code gives me the following errors: > > slp.grm.sml:164.46-164.49 Error: unbound type constructor: stm > slp.grm.sml:164.21-164.24 Error: unbound type constructor: stm > slp.grm.sml:163.51-163.54 Error: unbound type constructor: exp > slp.grm.sml:163.22-163.25 Error: unbound type constructor: exp > slp.grm.sml:167.15-167.18 Error: unbound type constructor: stm > > I would appreciate any help in resolving these errors. The version > of SML/NJ I'm using is 110.68, and I have attached the grammar file > below. > > > structure Absyn = struct > type id = string > datatype binop = Plus | Minus | Times | Div > datatype stm = CompoundStm of stm * stm > | AssignStm of id * exp > | PrintStm of exp list > and exp = IdExp of id > | NumExp of int > | OpExp of exp * binop * exp > | EseqExp of stm * exp > end > structure A = Absyn > %% > %term INT of int | ID of string | PLUS | MINUS | TIMES | DIV > | ASSIGN | PRINT | LPAREN | RPAREN | COMMA | SEMICOL | EOF > %nonterm prog of stm | stm of stm | exp of exp | exps of exp list > %right SEMICOL > %left PLUS MINUS > %left TIMES DIV > %start prog > %eop EOF > %noshift EOF > %pos int > %name Slp > %% > prog: stm (stm) > > stm: stm SEMICOL stm (A.CompoundStm(stm1, stm2)) > stm: ID ASSIGN exp (A.AssignStm(ID, exp)) > stm: PRINT LPAREN exps RPAREN (A.PrintStm(exps)) > > exps: exp (exp :: nil) > exps: exp COMMA exps (exp :: exps) > > exp: INT (A.NumExp(INT)) > exp: ID (A.IdExp(ID)) > exp: exp PLUS exp (A.OpExp(exp1, A.Plus, exp2)) > exp: exp MINUS exp (A.OpExp(exp1, A.Minus, exp2)) > exp: exp TIMES exp (A.OpExp(exp1, A.Times, exp2)) > exp: exp DIV exp (A.OpExp(exp1, A.Div, exp2)) > exp: stm COMMA exp (A.EseqExp(stm, exp)) > exp: LPAREN exp RPAREN (exp) > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword_______________________________________________ > Smlnj-list mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/smlnj-list ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword