%{ open Fnlib Config Mixture Const Globals Location Types Asynt Asyntfn; fun rev acc [] = acc| rev acc (h::t) = rev (h::acc) t; val anonId = "?";val anonQualId = {qual = "",id =[anonId]}; val mkDerivedfunbind = fn (funid,funsort,modid,sigexp,modexp) => FUNBINDfunbind(funid,(xxLR modid modexp, (FUNCTORmodexp(funsort,modid,ref VARik,sigexp,modexp),ref NONE))) local fun flattenDec (dec as (loc,dec')) acc = case dec' of SEQdec (dec1,dec2) => flattenDec dec1 (flattenDec dec2 acc) | _ => dec::accinfun mkDerivedDecs (locmodexp as (loc,(modexp',_))) = case modexp' of DECmodexp dec => flattenDec dec [] | _ => [(loc,LOCALdec ((loc,STRUCTUREdec [MODBINDmodbind((loc,anonId),locmodexp)]), (loc,OPENdec [(mkIdInfo (loc,anonQualId) false,ref NONE)])))]end; %} %token ABSTYPE%token AND%token ANDALSO%token ARROW%token AS%token BAR%token CASE%token <char> CHAR%token COLON%token COLONGT%token COMMA%token DARROW%token DATATYPE%token DLBRACE%token DO%token DOTDOTDOT%token DRBRACE%token ELSE%token END%token EOF%token EQTYPE%token EQUALS%token EXCEPTION%token FN%token FUN%token FUNCTOR%token HANDLE%token HASH%token HASHLBRACKET%token <string> ID%token IF%token IN%token INCLUDE%token INFIX%token INFIXR%token LBRACE%token LBRACKET%token LET%token LOCAL%token LPAREN%token <int> NEGINT%token NONFIX%token <int> NZDIGIT%token <int> NZPOSINT2%token OF%token OP%token OPEN%token ORELSE%token PRIM_EQTYPE%token PRIM_REFTYPE%token PRIM_TYPE%token PRIM_VAL%token <Const.QualifiedIdent> QUAL_ID%token <Const.QualifiedIdent> QUAL_STAR%token QUOTEL%token <string> QUOTEM%token <string> QUOTER%token RAISE%token RBRACE%token RBRACKET%token <real> REAL%token REC%token RPAREN%token SEMICOLON%token SHARING%token SIG%token SIGNATURE%token STAR%token <string> STRING%token STRUCT%token STRUCTURE%token THEN%token TYPE%token <string> TYVAR%token UNDERBAR%token VAL%token WHERE%token WHILE%token WITH%token WITHTYPE%token <word> WORD%token <int> ZDIGIT %token <int> ZPOSINT2 %right AND%nonassoc DARROW%nonassoc BAR%nonassoc ELSE%nonassoc DO%nonassoc RAISE%right HANDLE%right ORELSE%right ANDALSO%right AS /* cvr: in Mosml144, COLON was nonassociative but this conflicts with the modexp COLON SigExp production *//* %nonassoc COLON */ %right ARROW%nonassoc ID EQUALS%right STAR %start ToplevelPhrase%type <Asynt.Dec * bool> ToplevelPhrase %start SigFile%type <Asynt.Sig> SigFile %start StructFile %type <Asynt.Struct> StructFile %start TopSpecFile%type <Asynt.Sig> TopSpecFile %start TopDecFile%type <Asynt.Struct> TopDecFile %type <bool> EOPh%type <string> Ident EqIdent %type <Location.Location * string> IdentWithLoc %type <Asynt.IdInfo> OpIdent TypeIdent LongTypeIdent%type <Asynt.IdInfo> LongIdent LongOpIdent LongOpEqIdent%type <Asynt.TyVar> TyVar%type <Asynt.TyCon> TyCon%type <Asynt.ModId> ModId%type <Asynt.SigId> SigId %type <string list> EqIdent_seq1 %type <int> DIGIT_opt Integer NumLabel Arity%type <unit> SemiEof%type <Mixture.Lab> Label%type <Const.SCon> SCon%type <Asynt.Dec> Dec KWDec_seq1 KWDec KWCoreDec KWModuleDec%type <Asynt.Dec list> KWDec_seq KWCoreDec_seq %type <Asynt.ValBind list * Asynt.ValBind list> ValBind AndValBind_opt%type <Asynt.PrimValBind list> PrimValBind AndPrimValBind_opt%type <Asynt.ValBind list> FnValBind AndFnValBind_opt%type <Asynt.TypBind list> TypBind AndTypBind_opt%type <Asynt.TypDesc list> TypDesc AndTypDesc_opt%type <Asynt.DatBind list> DatBind AndDatBind_opt DatBind_0 DatBind_n%type <Asynt.ConBind list> ConBind BarConBind_opt%type <Asynt.TypBind list option> WithType_opt%type <Asynt.ExBind list> ExBind AndExBind_opt%type <Asynt.ExDesc list> ExDesc AndExDesc_opt%type <Asynt.Ty option> OfTy_opt ColonTy_opt%type <Asynt.FValBind list> FValBind AndFValBind_opt%type <Asynt.FValBind> FClauseWithLoc%type <Asynt.FClause list> FClause BarFClause_opt%type <Asynt.VIdPathInfo> VIdPathInfo%type <Asynt.InfixExp> InfixExp%type <Asynt.Exp> AtExp Exp%type <Asynt.Exp list> ExpComma_seq0 ExpComma_seq1 ExpComma_seq2 QuoteTail ExpQuoteTail %type <Asynt.Exp list> ExpSemicolon_seq2%type <Asynt.Exp list> AtExp_seq1%type <Asynt.Exp Mixture.Row> ExpRow_opt ExpRow CommaExpRow_opt%type <Asynt.Match> Match%type <Location.Location * Asynt.Match> MatchWithLoc%type <Asynt.MRule> MRule%type <Asynt.InfixPat> InfixPat%type <Asynt.Pat> Pat AtPat%type <Asynt.Pat list> AtPat_seq1%type <Asynt.Pat list> PatComma_seq0 PatComma_seq1 PatComma_seq2%type <Asynt.Pat Mixture.Row * bool> PatRow_opt PatRow CommaPatRow_opt%type <Asynt.Pat option> AsPat_opt%type <Asynt.TyConPath> TyConPath%type <Asynt.Ty> Ty Ty_sans_STAR AtomicTy%type <Asynt.Ty list> TupleTy TyComma_seq2%type <Asynt.Ty Mixture.Row> TyRow_opt TyRow CommaTyRow_opt%type <Asynt.TyVar list> TyVarSeq TyVarSeq1 TyVarComma_seq1%type <Asynt.Spec> Spec KWSpec KWCoreSpec KWModuleSpec%type <Asynt.Spec list> Spec_seq CoreSpec_seq%type <Asynt.ValDesc list> ValDesc AndValDesc_opt%type <Asynt.LongModId> LongModId%type <Asynt.LongModIdInfo list> LongModIdInfo_seq1%type <Asynt.ModBind list> ModBind_seq1 AndModBind_opt%type <Asynt.FunBind list> FunBind_seq1 AndFunBind_opt%type <Asynt.SigBind list> SigBind_seq1 AndSigBind_opt%type <Asynt.ModExp> AtModExp ModExp FunBindBody OptConEqualsModExp%type <Asynt.ModExp list> AtModExp_seq1%type <Asynt.ModDesc list> ModDesc_seq1 AndModDesc_opt%type <Asynt.FunDesc list> FunDesc_seq1 AndFunDesc_opt%type <Asynt.SigExp> SigExp FunDescBody %type <Asynt.SigId list> SigId_seq2%type <Asynt.LongTyCon list> LongTyConEqn LongTyConEqnTail%type <Asynt.LongModId list> LongModIdEqnTail LongModIdEqn %type <Location * (Asynt.LongModId list)> LongModIdEqnWithLoc %type <(Location * (Asynt.TyVarSeq * Asynt.LongTyCon * Asynt.Ty)) list> WhereType AndWhereType_opt%type <(Asynt.ModId * ModExp) option> WhereModBind_opt %% Ident : ID { $1 } | STAR { "*" }; IdentWithLoc : Ident { mkLoc($1) }; OpIdent : Ident { mkIdInfo (mkLoc { qual="", id=[$1] }) false } | OP Ident { mkIdInfo (mkLoc { qual="", id=[$2] }) true }; EqIdent : Ident { $1 } | EQUALS { "=" }; ModId : IdentWithLoc { $1 }; SigId : IdentWithLoc { $1 }; TypeIdent : ID { mkIdInfo (mkLoc { qual="", id=[$1] }) false }; LongTypeIdent : TypeIdent { $1 } | QUAL_ID { mkIdInfo (mkLoc $1) false }; LongIdent : Ident { mkIdInfo (mkLoc { qual="", id=[$1] }) false } | QUAL_ID { mkIdInfo (mkLoc $1) false } | QUAL_STAR { mkIdInfo (mkLoc $1) false }; LongOpIdent : LongIdent { $1 } | OP Ident { mkIdInfo (mkLoc { qual="", id=[$2] }) true } | OP QUAL_ID { mkIdInfo (mkLoc $2) true } | OP QUAL_STAR { mkIdInfo (mkLoc $2) true }; LongOpEqIdent : LongOpIdent { $1 } | EQUALS { mkIdInfo (mkLoc { qual="", id=["="] }) false } | OP EQUALS { mkIdInfo (mkLoc { qual="", id=["="] }) true }; TyVar : TYVAR { mkIdInfo (mkLoc { qual="", id=[$1] }) false }; EqIdent_seq1 : EqIdent EqIdent_seq1 { $1 :: $2 } | EqIdent { [$1] }; LongModId : LongOpIdent {$1} LongModIdInfo_seq1 : LongModId LongModIdInfo_seq1 { (($1,ref NONE)) :: $2 } | LongModId { [($1, ref NONE)] }; DIGIT_opt : ZDIGIT { $1 } | NZDIGIT { $1 } | /* */ { 0 }; Integer : ZPOSINT2 { $1 } | NZPOSINT2 { $1 } | NEGINT { $1 } | ZDIGIT { $1 } | NZDIGIT { $1 }; NumLabel : NZPOSINT2 { $1 } | NZDIGIT { $1 }; Label : Ident { STRINGlab $1 } | NumLabel { INTlab $1 }; Arity : ZPOSINT2 { $1 } | NZPOSINT2 { $1 } | ZDIGIT { $1 } | NZDIGIT { $1 }; ToplevelPhrase : Exp EOPh { (mkValIt $1, $2) } | KWDec_seq1 EOPh { ($1, $2) } | EOPh { (mkLoc(EMPTYdec), $1) }; EOPh : SEMICOLON { false } | EOF { true }; SemiEof : SEMICOLON SemiEof { } | EOF { }; Dec : KWDec Dec { mkLoc(SEQdec($1, $2)) } | SEMICOLON Dec { $2 } | /* */ { mkLoc(EMPTYdec) }; KWDec_seq1 : KWDec KWDec_seq1 { mkLoc(SEQdec($1,$2)) } | KWDec { $1 }; TopDecFile : KWDec_seq EOF { TopDecs $1 } /* cvr: TODO allow expressions? */; StructFile : STRUCTURE ModId EQUALS ModExp SemiEof { NamedStruct{locstrid = $2, locsigid = NONE, decs = mkDerivedDecs $4} } | STRUCTURE ModId COLONGT SigId EQUALS ModExp SemiEof { Abstraction{locstrid = $2, locsigid = $4, decs = mkDerivedDecs $6} } | KWCoreDec_seq EOF { AnonStruct $1 } /* backwards compatability mode * */; KWDec_seq : KWDec KWDec_seq { $1 :: $2 } | SEMICOLON KWDec_seq { $2 } | /* */ { [] }; KWCoreDec_seq : KWCoreDec KWCoreDec_seq { $1 :: $2 } | SEMICOLON KWCoreDec_seq { $2 } | /* */ { [] }; KWDec : KWCoreDec {$1}| KWModuleDec {$1}; KWModuleDec: STRUCTURE ModBind_seq1 { mkLoc(STRUCTUREdec $2)} | FUNCTOR FunBind_seq1 { mkLoc(FUNCTORdec $2)} | SIGNATURE SigBind_seq1 { mkLoc(SIGNATUREdec $2)}; KWCoreDec : VAL ValBind { mkLoc(VALdec ([], $2)) } /* cvr: REVIEW */ | VAL TyVarSeq1 ValBind { mkLoc(VALdec ($2, $3)) } | PRIM_VAL PrimValBind { mkLoc(PRIM_VALdec ([],$2)) } /* cvr: REVIEW */ | PRIM_VAL TyVarSeq1 PrimValBind { mkLoc(PRIM_VALdec ($2,$3)) } | FUN FValBind { mkLoc(FUNdec (ref (UNRESfundec([], $2)))) } | FUN TyVarSeq1 FValBind { mkLoc(FUNdec (ref (UNRESfundec($2, $3)))) } | TYPE TypBind { mkLoc(TYPEdec $2) } | PRIM_TYPE TypDesc { mkLoc(PRIM_TYPEdec(FALSEequ, $2)) } | PRIM_EQTYPE TypDesc { mkLoc(PRIM_TYPEdec(TRUEequ, $2)) } | PRIM_REFTYPE TypDesc { mkLoc(PRIM_TYPEdec(REFequ, $2)) } | DATATYPE DatBind_0 WithType_opt { mkLoc(DATATYPEdec($2,$3)) } | DATATYPE DatBind_n WithType_opt { mkLoc(DATATYPEdec($2,$3)) } /* cvr: this simpler production cause a shift/reduce conflict with datatype replication | DATATYPE DatBind WithType_opt { mkLoc(DATATYPEdec($2,$3)) } */ | DATATYPE TyCon EQUALS DATATYPE TyConPath { mkLoc(DATATYPErepdec($2,$5))} | ABSTYPE DatBind WithType_opt WITH Dec END { mkLoc(ABSTYPEdec($2,$3,$5)) } | EXCEPTION ExBind { mkLoc(EXCEPTIONdec $2) } | LOCAL Dec IN Dec END { mkLoc(LOCALdec($2,$4)) } | OPEN LongModIdInfo_seq1 { mkLoc(OPENdec $2) } | INFIX DIGIT_opt EqIdent_seq1 { mkLoc(FIXITYdec(INFIXst $2, $3)) } | INFIXR DIGIT_opt EqIdent_seq1 { mkLoc(FIXITYdec(INFIXRst $2, $3)) } | NONFIX EqIdent_seq1 { mkLoc(FIXITYdec(NONFIXst, $2)) }; ValBind : Pat EQUALS Exp AndValBind_opt { let val (pvbs, rvbs) = $4 in (ValBind(ref $1, $3)::pvbs, rvbs) end } | REC FnValBind { ([], $2) }; AndValBind_opt : AND ValBind { $2 } | /* */ { ([], []) }; PrimValBind : OpIdent COLON Ty EQUALS Arity STRING AndPrimValBind_opt { ($1, $3, $5, $6) :: $7 }; AndPrimValBind_opt : AND PrimValBind { $2 } | /* */ { [] }; FnValBind : Pat EQUALS Exp AndFnValBind_opt { ValBind(ref $1, $3) :: $4 } | REC FnValBind { $2 }; AndFnValBind_opt : AND FnValBind { $2 } | /* */ { [] }; TypBind : TyVarSeq TyCon EQUALS Ty AndTypBind_opt { ($1, $2, $4) :: $5 }; AndTypBind_opt : AND TypBind { $2 } | /* */ { [] }; DatBind : TyVarSeq TyCon EQUALS ConBind AndDatBind_opt { ($1, $2, $4) :: $5 }; DatBind_0 : TyCon EQUALS ConBind AndDatBind_opt { ([], $1, $3) :: $4 }; DatBind_n : TyVarSeq1 TyCon EQUALS ConBind AndDatBind_opt { ($1, $2, $4) :: $5 }; AndDatBind_opt : AND DatBind { $2 } | /* */ { [] }; ConBind : OpIdent OfTy_opt BarConBind_opt { ConBind($1, $2) :: $3 }; BarConBind_opt :Lines 1–500 of 1172. Load more
%{ open Fnlib Config Mixture Const Globals Location Types Asynt Asyntfn; fun rev acc [] = acc | rev acc (h::t) = rev (h::acc) t; val anonId = "?"; val anonQualId = {qual = "",id =[anonId]}; val mkDerivedfunbind = fn (funid,funsort,modid,sigexp,modexp) => FUNBINDfunbind(funid,(xxLR modid modexp, (FUNCTORmodexp(funsort,modid,ref VARik,sigexp,modexp),ref NONE))) local fun flattenDec (dec as (loc,dec')) acc = case dec' of SEQdec (dec1,dec2) => flattenDec dec1 (flattenDec dec2 acc) | _ => dec::acc in fun mkDerivedDecs (locmodexp as (loc,(modexp',_))) = case modexp' of DECmodexp dec => flattenDec dec [] | _ => [(loc,LOCALdec ((loc,STRUCTUREdec [MODBINDmodbind((loc,anonId),locmodexp)]), (loc,OPENdec [(mkIdInfo (loc,anonQualId) false,ref NONE)])))] end ; %} %token ABSTYPE %token AND %token ANDALSO %token ARROW %token AS %token BAR %token CASE %token <char> CHAR %token COLON %token COLONGT %token COMMA %token DARROW %token DATATYPE %token DLBRACE %token DO %token DOTDOTDOT %token DRBRACE %token ELSE %token END %token EOF %token EQTYPE %token EQUALS %token EXCEPTION %token FN %token FUN %token FUNCTOR %token HANDLE %token HASH %token HASHLBRACKET %token <string> ID %token IF %token IN %token INCLUDE %token INFIX %token INFIXR %token LBRACE %token LBRACKET %token LET %token LOCAL %token LPAREN %token <int> NEGINT %token NONFIX %token <int> NZDIGIT %token <int> NZPOSINT2 %token OF %token OP %token OPEN %token ORELSE %token PRIM_EQTYPE %token PRIM_REFTYPE %token PRIM_TYPE %token PRIM_VAL %token <Const.QualifiedIdent> QUAL_ID %token <Const.QualifiedIdent> QUAL_STAR %token QUOTEL %token <string> QUOTEM %token <string> QUOTER %token RAISE %token RBRACE %token RBRACKET %token <real> REAL %token REC %token RPAREN %token SEMICOLON %token SHARING %token SIG %token SIGNATURE %token STAR %token <string> STRING %token STRUCT %token STRUCTURE %token THEN %token TYPE %token <string> TYVAR %token UNDERBAR %token VAL %token WHERE %token WHILE %token WITH %token WITHTYPE %token <word> WORD %token <int> ZDIGIT %token <int> ZPOSINT2 %right AND %nonassoc DARROW %nonassoc BAR %nonassoc ELSE %nonassoc DO %nonassoc RAISE %right HANDLE %right ORELSE %right ANDALSO %right AS /* cvr: in Mosml144, COLON was nonassociative but this conflicts with the modexp COLON SigExp production */ /* %nonassoc COLON */ %right ARROW %nonassoc ID EQUALS %right STAR %start ToplevelPhrase %type <Asynt.Dec * bool> ToplevelPhrase %start SigFile %type <Asynt.Sig> SigFile %start StructFile %type <Asynt.Struct> StructFile %start TopSpecFile %type <Asynt.Sig> TopSpecFile %start TopDecFile %type <Asynt.Struct> TopDecFile %type <bool> EOPh %type <string> Ident EqIdent %type <Location.Location * string> IdentWithLoc %type <Asynt.IdInfo> OpIdent TypeIdent LongTypeIdent %type <Asynt.IdInfo> LongIdent LongOpIdent LongOpEqIdent %type <Asynt.TyVar> TyVar %type <Asynt.TyCon> TyCon %type <Asynt.ModId> ModId %type <Asynt.SigId> SigId %type <string list> EqIdent_seq1 %type <int> DIGIT_opt Integer NumLabel Arity %type <unit> SemiEof %type <Mixture.Lab> Label %type <Const.SCon> SCon %type <Asynt.Dec> Dec KWDec_seq1 KWDec KWCoreDec KWModuleDec %type <Asynt.Dec list> KWDec_seq KWCoreDec_seq %type <Asynt.ValBind list * Asynt.ValBind list> ValBind AndValBind_opt %type <Asynt.PrimValBind list> PrimValBind AndPrimValBind_opt %type <Asynt.ValBind list> FnValBind AndFnValBind_opt %type <Asynt.TypBind list> TypBind AndTypBind_opt %type <Asynt.TypDesc list> TypDesc AndTypDesc_opt %type <Asynt.DatBind list> DatBind AndDatBind_opt DatBind_0 DatBind_n %type <Asynt.ConBind list> ConBind BarConBind_opt %type <Asynt.TypBind list option> WithType_opt %type <Asynt.ExBind list> ExBind AndExBind_opt %type <Asynt.ExDesc list> ExDesc AndExDesc_opt %type <Asynt.Ty option> OfTy_opt ColonTy_opt %type <Asynt.FValBind list> FValBind AndFValBind_opt %type <Asynt.FValBind> FClauseWithLoc %type <Asynt.FClause list> FClause BarFClause_opt %type <Asynt.VIdPathInfo> VIdPathInfo %type <Asynt.InfixExp> InfixExp %type <Asynt.Exp> AtExp Exp %type <Asynt.Exp list> ExpComma_seq0 ExpComma_seq1 ExpComma_seq2 QuoteTail ExpQuoteTail %type <Asynt.Exp list> ExpSemicolon_seq2 %type <Asynt.Exp list> AtExp_seq1 %type <Asynt.Exp Mixture.Row> ExpRow_opt ExpRow CommaExpRow_opt %type <Asynt.Match> Match %type <Location.Location * Asynt.Match> MatchWithLoc %type <Asynt.MRule> MRule %type <Asynt.InfixPat> InfixPat %type <Asynt.Pat> Pat AtPat %type <Asynt.Pat list> AtPat_seq1 %type <Asynt.Pat list> PatComma_seq0 PatComma_seq1 PatComma_seq2 %type <Asynt.Pat Mixture.Row * bool> PatRow_opt PatRow CommaPatRow_opt %type <Asynt.Pat option> AsPat_opt %type <Asynt.TyConPath> TyConPath %type <Asynt.Ty> Ty Ty_sans_STAR AtomicTy %type <Asynt.Ty list> TupleTy TyComma_seq2 %type <Asynt.Ty Mixture.Row> TyRow_opt TyRow CommaTyRow_opt %type <Asynt.TyVar list> TyVarSeq TyVarSeq1 TyVarComma_seq1 %type <Asynt.Spec> Spec KWSpec KWCoreSpec KWModuleSpec %type <Asynt.Spec list> Spec_seq CoreSpec_seq %type <Asynt.ValDesc list> ValDesc AndValDesc_opt %type <Asynt.LongModId> LongModId %type <Asynt.LongModIdInfo list> LongModIdInfo_seq1 %type <Asynt.ModBind list> ModBind_seq1 AndModBind_opt %type <Asynt.FunBind list> FunBind_seq1 AndFunBind_opt %type <Asynt.SigBind list> SigBind_seq1 AndSigBind_opt %type <Asynt.ModExp> AtModExp ModExp FunBindBody OptConEqualsModExp %type <Asynt.ModExp list> AtModExp_seq1 %type <Asynt.ModDesc list> ModDesc_seq1 AndModDesc_opt %type <Asynt.FunDesc list> FunDesc_seq1 AndFunDesc_opt %type <Asynt.SigExp> SigExp FunDescBody %type <Asynt.SigId list> SigId_seq2 %type <Asynt.LongTyCon list> LongTyConEqn LongTyConEqnTail %type <Asynt.LongModId list> LongModIdEqnTail LongModIdEqn %type <Location * (Asynt.LongModId list)> LongModIdEqnWithLoc %type <(Location * (Asynt.TyVarSeq * Asynt.LongTyCon * Asynt.Ty)) list> WhereType AndWhereType_opt %type <(Asynt.ModId * ModExp) option> WhereModBind_opt %% Ident : ID { $1 } | STAR { "*" } ; IdentWithLoc : Ident { mkLoc($1) } ; OpIdent : Ident { mkIdInfo (mkLoc { qual="", id=[$1] }) false } | OP Ident { mkIdInfo (mkLoc { qual="", id=[$2] }) true } ; EqIdent : Ident { $1 } | EQUALS { "=" } ; ModId : IdentWithLoc { $1 } ; SigId : IdentWithLoc { $1 } ; TypeIdent : ID { mkIdInfo (mkLoc { qual="", id=[$1] }) false } ; LongTypeIdent : TypeIdent { $1 } | QUAL_ID { mkIdInfo (mkLoc $1) false } ; LongIdent : Ident { mkIdInfo (mkLoc { qual="", id=[$1] }) false } | QUAL_ID { mkIdInfo (mkLoc $1) false } | QUAL_STAR { mkIdInfo (mkLoc $1) false } ; LongOpIdent : LongIdent { $1 } | OP Ident { mkIdInfo (mkLoc { qual="", id=[$2] }) true } | OP QUAL_ID { mkIdInfo (mkLoc $2) true } | OP QUAL_STAR { mkIdInfo (mkLoc $2) true } ; LongOpEqIdent : LongOpIdent { $1 } | EQUALS { mkIdInfo (mkLoc { qual="", id=["="] }) false } | OP EQUALS { mkIdInfo (mkLoc { qual="", id=["="] }) true } ; TyVar : TYVAR { mkIdInfo (mkLoc { qual="", id=[$1] }) false } ; EqIdent_seq1 : EqIdent EqIdent_seq1 { $1 :: $2 } | EqIdent { [$1] } ; LongModId : LongOpIdent {$1} LongModIdInfo_seq1 : LongModId LongModIdInfo_seq1 { (($1,ref NONE)) :: $2 } | LongModId { [($1, ref NONE)] } ; DIGIT_opt : ZDIGIT { $1 } | NZDIGIT { $1 } | /* */ { 0 } ; Integer : ZPOSINT2 { $1 } | NZPOSINT2 { $1 } | NEGINT { $1 } | ZDIGIT { $1 } | NZDIGIT { $1 } ; NumLabel : NZPOSINT2 { $1 } | NZDIGIT { $1 } ; Label : Ident { STRINGlab $1 } | NumLabel { INTlab $1 } ; Arity : ZPOSINT2 { $1 } | NZPOSINT2 { $1 } | ZDIGIT { $1 } | NZDIGIT { $1 } ; ToplevelPhrase : Exp EOPh { (mkValIt $1, $2) } | KWDec_seq1 EOPh { ($1, $2) } | EOPh { (mkLoc(EMPTYdec), $1) } ; EOPh : SEMICOLON { false } | EOF { true } ; SemiEof : SEMICOLON SemiEof { } | EOF { } ; Dec : KWDec Dec { mkLoc(SEQdec($1, $2)) } | SEMICOLON Dec { $2 } | /* */ { mkLoc(EMPTYdec) } ; KWDec_seq1 : KWDec KWDec_seq1 { mkLoc(SEQdec($1,$2)) } | KWDec { $1 } ; TopDecFile : KWDec_seq EOF { TopDecs $1 } /* cvr: TODO allow expressions? */ ; StructFile : STRUCTURE ModId EQUALS ModExp SemiEof { NamedStruct{locstrid = $2, locsigid = NONE, decs = mkDerivedDecs $4} } | STRUCTURE ModId COLONGT SigId EQUALS ModExp SemiEof { Abstraction{locstrid = $2, locsigid = $4, decs = mkDerivedDecs $6} } | KWCoreDec_seq EOF { AnonStruct $1 } /* backwards compatability mode * */ ; KWDec_seq : KWDec KWDec_seq { $1 :: $2 } | SEMICOLON KWDec_seq { $2 } | /* */ { [] } ; KWCoreDec_seq : KWCoreDec KWCoreDec_seq { $1 :: $2 } | SEMICOLON KWCoreDec_seq { $2 } | /* */ { [] } ; KWDec : KWCoreDec {$1} | KWModuleDec {$1} ; KWModuleDec: STRUCTURE ModBind_seq1 { mkLoc(STRUCTUREdec $2)} | FUNCTOR FunBind_seq1 { mkLoc(FUNCTORdec $2)} | SIGNATURE SigBind_seq1 { mkLoc(SIGNATUREdec $2)} ; KWCoreDec : VAL ValBind { mkLoc(VALdec ([], $2)) } /* cvr: REVIEW */ | VAL TyVarSeq1 ValBind { mkLoc(VALdec ($2, $3)) } | PRIM_VAL PrimValBind { mkLoc(PRIM_VALdec ([],$2)) } /* cvr: REVIEW */ | PRIM_VAL TyVarSeq1 PrimValBind { mkLoc(PRIM_VALdec ($2,$3)) } | FUN FValBind { mkLoc(FUNdec (ref (UNRESfundec([], $2)))) } | FUN TyVarSeq1 FValBind { mkLoc(FUNdec (ref (UNRESfundec($2, $3)))) } | TYPE TypBind { mkLoc(TYPEdec $2) } | PRIM_TYPE TypDesc { mkLoc(PRIM_TYPEdec(FALSEequ, $2)) } | PRIM_EQTYPE TypDesc { mkLoc(PRIM_TYPEdec(TRUEequ, $2)) } | PRIM_REFTYPE TypDesc { mkLoc(PRIM_TYPEdec(REFequ, $2)) } | DATATYPE DatBind_0 WithType_opt { mkLoc(DATATYPEdec($2,$3)) } | DATATYPE DatBind_n WithType_opt { mkLoc(DATATYPEdec($2,$3)) } /* cvr: this simpler production cause a shift/reduce conflict with datatype replication | DATATYPE DatBind WithType_opt { mkLoc(DATATYPEdec($2,$3)) } */ | DATATYPE TyCon EQUALS DATATYPE TyConPath { mkLoc(DATATYPErepdec($2,$5))} | ABSTYPE DatBind WithType_opt WITH Dec END { mkLoc(ABSTYPEdec($2,$3,$5)) } | EXCEPTION ExBind { mkLoc(EXCEPTIONdec $2) } | LOCAL Dec IN Dec END { mkLoc(LOCALdec($2,$4)) } | OPEN LongModIdInfo_seq1 { mkLoc(OPENdec $2) } | INFIX DIGIT_opt EqIdent_seq1 { mkLoc(FIXITYdec(INFIXst $2, $3)) } | INFIXR DIGIT_opt EqIdent_seq1 { mkLoc(FIXITYdec(INFIXRst $2, $3)) } | NONFIX EqIdent_seq1 { mkLoc(FIXITYdec(NONFIXst, $2)) } ; ValBind : Pat EQUALS Exp AndValBind_opt { let val (pvbs, rvbs) = $4 in (ValBind(ref $1, $3)::pvbs, rvbs) end } | REC FnValBind { ([], $2) } ; AndValBind_opt : AND ValBind { $2 } | /* */ { ([], []) } ; PrimValBind : OpIdent COLON Ty EQUALS Arity STRING AndPrimValBind_opt { ($1, $3, $5, $6) :: $7 } ; AndPrimValBind_opt : AND PrimValBind { $2 } | /* */ { [] } ; FnValBind : Pat EQUALS Exp AndFnValBind_opt { ValBind(ref $1, $3) :: $4 } | REC FnValBind { $2 } ; AndFnValBind_opt : AND FnValBind { $2 } | /* */ { [] } ; TypBind : TyVarSeq TyCon EQUALS Ty AndTypBind_opt { ($1, $2, $4) :: $5 } ; AndTypBind_opt : AND TypBind { $2 } | /* */ { [] } ; DatBind : TyVarSeq TyCon EQUALS ConBind AndDatBind_opt { ($1, $2, $4) :: $5 } ; DatBind_0 : TyCon EQUALS ConBind AndDatBind_opt { ([], $1, $3) :: $4 } ; DatBind_n : TyVarSeq1 TyCon EQUALS ConBind AndDatBind_opt { ($1, $2, $4) :: $5 } ; AndDatBind_opt : AND DatBind { $2 } | /* */ { [] } ; ConBind : OpIdent OfTy_opt BarConBind_opt { ConBind($1, $2) :: $3 } ; BarConBind_opt :