Include [SaffronAG, SaffronTreeDecls, SaffronBaseDecls];
SaffronMakeFieldList: Module = Begin
for RecList.empty: 	AbstractProduction [ ]
let MakeFieldList [tree, localContext, paintRecords, cs ] _ 
< FakeDamageContext[localContext], CreateEmptyFieldList []>
;
for RecList.pairlist: 	AbstractProduction [ PairList ]
let MakeFieldList [tree, localContext, paintRecords, cs] _ <localContext1, fieldList>
where <localContext1, fieldList> _ 
AddPairsToFieldList [PairList, localContext, newFieldList, paintRecords, cs]
where newFieldList _ CreateEmptyFieldList []
;
for RecList.typelist:	AbstractProduction [ TypeList ]
let MakeFieldList [tree, localContext, paintRecords, cs] _ <localContext1, fieldList>
where <localContext1, fieldList> _ AddToFieldList [TypeList, localContext, newFieldList, paintRecords, cs]
where newFieldList _ CreateEmptyFieldList []
;
for ParameterList.empty:	AbstractProduction [ ]
let MakeFieldList [tree, localContext, paintRecords, cs ] _ 
	<FakeDamageContext[localContext], CreateEmptyFieldList []>
;
for ParameterList.any:	AbstractProduction [ ]
let MakeFieldList [tree, localContext, paintRecords, cs] _ 
						<FakeDamageContext [localContext], AnyFieldList []>
;
for ParameterList.pairlist:	AbstractProduction [ PairList ]
let MakeFieldList [tree, localContext, paintRecords, cs] _ <localContext1, fieldList>
where <localContext1, fieldList> _ 
AddPairsToFieldList [PairList, localContext, newFieldList, paintRecords, cs]
where newFieldList _ CreateEmptyFieldList []
;
for ParameterList.typelist:	AbstractProduction [ TypeList ]
let MakeFieldList [tree, localContext, paintRecords, cs] _ <localContext1, fieldList>
where <localContext1, fieldList> _ AddToFieldList [TypeList, localContext, newFieldList, paintRecords, cs]
where newFieldList _ CreateEmptyFieldList []
;
for VariantList.one:	AbstractProduction [ VariantItem ]
let MakeUnionList [tree, localContext, paintRecords, cs] _
 AddVariantsToUnionList [VariantItem, localContext, newUnionList, paintRecords, cs]
where newUnionList _ CreateEmptyUnionList []
let AddVariantsToUnionList [tree, localContext, unionList, paintRecords, cs] _
 AddVariantsToUnionList [VariantItem, localContext, unionList, paintRecords, cs]
let MakeStarTagType [tree, localContext] _ <localContext2, tgn>
where localContext2 _
AddVariantNamesToEnumTypeTGN [VariantItem, localContext1, tgn]
where <localContext1, tgn> _ CreateEmptyEnumTypeTGN [localContext, False []]
let AddVariantNamesToEnumTypeTGN [tree, localContext, tgn] _
AddVariantNamesToEnumTypeTGN [VariantItem, localContext, tgn]
;
for VariantList.more:	AbstractProduction [ VariantList, VariantItem ]
let MakeUnionList [tree, localContext, paintRecords, cs] _
 AddVariantsToUnionList [VariantItem, localContext1, unionList, paintRecords, cs]
where <localContext1, unionList> _
AddVariantsToUnionList [VariantList, localContext, newUnionList, paintRecords, cs]
where newUnionList _ CreateEmptyUnionList []

let AddVariantsToUnionList [tree, localContext, unionList, paintRecords, cs] _
 AddVariantsToUnionList [VariantItem, localContext1, unionList1, paintRecords, cs]
where <localContext1, unionList1> _
AddVariantsToUnionList [VariantList, localContext, unionList, paintRecords, cs]
let MakeStarTagType [tree, localContext] _ <localContext3, tgn>
where localContext3 _ 
AddVariantNamesToEnumTypeTGN [VariantItem, localContext2, tgn]
where localContext2 _ 
AddVariantNamesToEnumTypeTGN [VariantList, localContext1, tgn]
where <localContext1, tgn> _ CreateEmptyEnumTypeTGN [localContext, False []]
let AddVariantNamesToEnumTypeTGN [tree, localContext, tgn] _
AddVariantNamesToEnumTypeTGN [VariantItem, localContext1, tgn]
where localContext1 _ 
AddVariantNamesToEnumTypeTGN [VariantList, localContext, tgn] 
;
for VariantItem:	AbstractProduction [ IdList, RecList ]
let AddVariantsToUnionList [tree, localContext, unionList, paintRecords, cs] _ < localContext1, AddNamesToUnionList [IdList, ffl, unionList]>
where ffl _ FreezeFieldList [fieldList]
where <localContext1, fieldList> _ MakeFieldList [RecList, localContext, paintRecords, cs ]
let AddVariantNamesToEnumTypeTGN [tree, localContext, tgn] _
AddVariantNamesToEnumTypeTGN [IdList, localContext, tgn]
;
for IdList.one:	AbstractProduction [ Id ]
let AddNamesToUnionList [tree, ffl, unionList] _ AppendToUnionList [unionList, Id, ffl]
let AddVariantNamesToEnumTypeTGN [tree, localContext, tgn] _
AppendElementToEnumTypeTGN [localContext, tgn, Id, MakeUnparsedNullValue[]]
let AddIdsToRestrictionList[tree, namedTGN] _ AddIdToRestrictionList[Id, namedTGN]
;
for IdList.more:	AbstractProduction [ Id, IdList ]
let AddNamesToUnionList [tree, ffl, unionList] _
AddNamesToUnionList [IdList, ffl, unionList1]
where unionList1 _ AppendToUnionList [unionList, Id, ffl]
let AddVariantNamesToEnumTypeTGN [tree, localContext, tgn] _
AddVariantNamesToEnumTypeTGN [IdList, localContext1, tgn]
where localContext1 _ AppendElementToEnumTypeTGN [localContext, tgn, Id, MakeUnparsedNullValue[]]
let AddIdsToRestrictionList[tree, tgn] _ tgn2
where tgn2 _ AddIdsToRestrictionList[IdList, tgn1]
where tgn1 _ AddIdToRestrictionList[Id, tgn]
;
for Tag.ident:	AbstractProduction [ Ident, Access, TagType ]
let MakeVariantFlavor [tree, cs] _ VanillaVariantFlavorVal [
GetIdentInfo [Ident], 
GetAccessVal [Access, GetDefaultAccess[cs]]]
let MakeTagType [tree, localContext, paintRecords, cs] _ 
MakeTagType [TagType, localContext, paintRecords, cs] 
let GetSequenceTagInfo [tree, cs] _ <GetIdentInfo [Ident], GetAccessVal [Access, GetDefaultAccess[cs]]>
;
for Tag.computed:	AbstractProduction [ TagType ]
let MakeVariantFlavor [tree, cs] _ ComputedVariantFlavorConst []
let MakeTagType [tree, localContext, paintRecords, cs] _ 
MakeTagType [TagType, localContext, paintRecords, cs] 
let GetSequenceTagInfo [tree, cs] _ <NullId [], NullPosition [], AccessValConst ["empty"]>
;
for Tag.overlaid:	AbstractProduction [ TagType ]
let MakeVariantFlavor [tree, cs] _ OverlaidVariantFlavorConst  []
let MakeTagType [tree, localContext, paintRecords, cs] _ 
MakeTagType [TagType, localContext, paintRecords, cs] 
let GetSequenceTagInfo [tree, cs] _ <NullId [], NullPosition [], AccessValConst ["empty"]>
where x _ Error ["Sequences can't be overlaid"]
;

for TagType.star:	AbstractProduction [ ]
let MakeTagType [tree, localContext, paintRecords, cs] _ 
<localContext1, GetBottom [cs], True []>
where localContext1 _ FakeDamageContext [localContext]
;
for TagType.typeexp:	AbstractProduction [ TypeExp ]
let MakeTagType [tree, localContext, paintRecords, cs] _ 
<MakeType [TypeExp, localContext, paintRecords, cs], False []>
;
End;

SaffronAddToFieldList: Module = Begin
for TypeList.many:	AbstractProduction [ TypeList.head, TypeList.tail ]
let AddToFieldList [tree, localContext, fieldList, paintRecords, cs] _ 
AddToFieldList [ TypeList.tail, localContext1, fieldList1, paintRecords, cs]
where <localContext1, fieldList1> _ 
AddToFieldList [ TypeList.head, localContext, fieldList, paintRecords, cs]
;
for TypeList.one:	AbstractProduction [ TypeItem ]
let AddToFieldList [tree, localContext, fieldList, paintRecords, cs] _  
AddToFieldList [ TypeItem, localContext, fieldList, paintRecords, cs]
;


for TypeItem:	AbstractProduction [ TypeExp, Default ]

let AddToFieldList [tree, localContext, fieldList, paintRecords, cs] _ <localContext1, fieldList1>
where fieldList1 _ AppendFieldToFieldList [ fieldList, field]
where field _ CreateUnnamedField [tgn, defaultExp]
where <localContext1, tgn> _ MakeType [TypeExp, localContext, paintRecords, cs]
where defaultExp _ GetDefaultExpVal [Default]
End;

SaffronAddPairsToFieldList: Module = Begin

for PairList.many:	AbstractProduction [ PairList.head, PairList.tail ]
let AddPairsToFieldList [tree, localContext, fieldList, paintRecords, cs] _
AddPairsToFieldList [ PairList.tail, localContext1, fieldList1, paintRecords, cs]
where <localContext1, fieldList1> _ 
AddPairsToFieldList [PairList.head, localContext, fieldList, paintRecords, cs]
;

for PairList.one:	AbstractProduction [ PairItem ]
let AddPairsToFieldList [tree, localContext, fieldList, paintRecords, cs] _
AddPairsToFieldList [PairItem, localContext, fieldList, paintRecords, cs]
;


for PairItem:	AbstractProduction [ IdentList, Access, TypeExp, Default ]
let AddPairsToFieldList [tree, localContext, fieldList, paintRecords, cs] _
< localContext1, AddNamesToFieldList [IdentList, accessVal, tgn, defaultExp, fieldList] >
where <localContext1, tgn> _ MakeType [TypeExp, localContext, paintRecords, cs]
where accessVal _ GetAccessVal [Access, GetDefaultAccess[cs]]
where defaultExp _ GetDefaultExpVal [Default]
;
for Access.empty:		AbstractProduction [ ]
let GetAccessVal [tree, default] _ FakeCopyAccessVal[default];
for Access.public:		AbstractProduction [ ]
let GetAccessVal [tree, default] _ AccessValConst ["public"];
for Access.private:	AbstractProduction [ ]
let GetAccessVal [tree, default] _ AccessValConst ["private"];

End;

SaffronAddNamesToFieldList: Module = Begin
for IdentList.many:	AbstractProduction [ IdentList.head, IdentList.tail ]
let AddNamesToFieldList [tree, accessVal, tgn, defaultExp, fieldList] _
AddNamesToFieldList [IdentList.tail, accessVal, tgn, defaultExp, fieldList1]
where fieldList1 _ AddNamesToFieldList [IdentList.head, accessVal, tgn, defaultExp, fieldList]
let MakeNameSequence [tree] _ AddNamesToSequence [IdentList.head, nameSequence1]
where nameSequence1 _ AddNamesToSequence [IdentList.tail, nameSequence]
where nameSequence _ EmptyNameSequence []
let AddNamesToSequence [tree, nameSequence] _ 
		AddNamesToSequence [IdentList.head, nameSequence1]
where nameSequence1 _ AddNamesToSequence [IdentList.tail, nameSequence]
;

for IdentList.one:	AbstractProduction [ Ident ]
let AddNamesToFieldList [tree, accessVal, tgn, defaultExp, fieldList] _
AddNamesToFieldList [Ident, accessVal, tgn, defaultExp, fieldList]
let MakeNameSequence [tree] _ AddNamesToSequence [Ident, nameSequence]
where nameSequence _ EmptyNameSequence []
let AddNamesToSequence [tree, nameSequence] _ 
		AddNamesToSequence [Ident, nameSequence]
;
for Ident.id:	AbstractProduction [ Id ]
let AddNamesToFieldList [tree, accessVal, tgn, defaultExp, fieldList] _
AppendFieldToFieldList [fieldList, field]
where field _ CreateNamedField [Id, NullPosition [], accessVal, tgn, defaultExp]
let GetIdentInfo [tree] _ <Id, NullPosition []>
let AddNamesToSequence [tree, nameSequence] _
		InsertNameOnNameSequence [Id, nameSequence]
;

for Ident.idposition:	AbstractProduction [ Id, Position ]
let AddNamesToFieldList [tree, accessVal, tgn,  defaultExp, fieldList] _
AppendFieldToFieldList [fieldList, field]
where field _ CreateNamedField [Id, GetPositionVal [Position], accessVal, tgn, defaultExp]
let GetIdentInfo [tree] _ <Id, GetPositionVal [Position]>
let AddNamesToSequence [tree, nameSequence] _
		InsertNameOnNameSequence [Id, nameSequence]
where x _ Error ["Is Position field valid in a ModuleName list"]
;
for Position:	AbstractProduction [ Exp, OptBits ]
let GetPositionVal [tree] _ PositionValFun [MakeUnparsedValue [Exp], boundsVal]
where boundsVal _ GetBoundsVal [OptBits]
;
for OptBits.absent:	AbstractProduction [ ]
let GetBoundsVal [tree] _ NullBounds []
;
for OptBits.present:	AbstractProduction [ Bounds ]
let GetBoundsVal [tree] _ BoundsValFun ["[", GetLowerAndUpper [Bounds], "]"]
;
End;

SaffronMakeElementList: Module = Begin
for ElementList.empty:	AbstractProduction [ ]
let MakeElementList [tree, localContext, machineDependent] _ CreateEmptyEnumTypeTGN [localContext, machineDependent]
;

for ElementList.more:	AbstractProduction [ ElementList, Element ]
let MakeElementList [tree, localContext, machineDependent] _ <localContext1, tgn>
where localContext1 _ 
AppendElementToEnumTypeTGN [localContext2, tgn, elementName, rep]
where <localContext2, tgn> _ MakeElementList [ElementList, localContext, machineDependent]
where <elementName, rep> _ ElementInfo [Element]


End;

SaffronElementName: Module = Begin
for Element.id:	AbstractProduction [ Id ]
let ElementInfo [tree] _ <Id, MakeUnparsedNullValue[]>
;

for Element.idwithrep:	AbstractProduction [ Id, Exp ]
let ElementInfo [tree] _ <Id, MakeUnparsedValue [Exp]>
;

for Element.anonymousrep:	AbstractProduction [ Exp ]
let ElementInfo [tree] _ <NullId [], MakeUnparsedValue [Exp]>
;
for Exp.id:	AbstractProduction [ Id ]
let IdVal [tree] _ Id
;
for Exp.sum:	AbstractProduction [ Exp.left, AddOp, Exp.right ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.unarysum:	AbstractProduction [ AddOp, Exp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.product:	AbstractProduction [ Exp.left, MultOp, Exp.right ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.or:	AbstractProduction [ Exp.left, Exp.right ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.and:	AbstractProduction [ Exp.left, Exp.right ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.not:	AbstractProduction [ Exp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.relation:	AbstractProduction [ Exp, Relation ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.ifthenelse:	AbstractProduction [ Exp.cond, Exp.thenpart, Exp.elsepart ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.select:	AbstractProduction [ SelectHead, SelectExpList, Exp.default ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.assign:	AbstractProduction [ Exp.lhs, Exp.rhs ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.multiassign:	AbstractProduction [ ExpList, Exp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.num:	AbstractProduction [ Num ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.string:	AbstractProduction [ String ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.flnum:	AbstractProduction [ Flnum ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.char:	AbstractProduction [ Char ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.atom:	AbstractProduction [ Atom ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.narrow:	AbstractProduction [ Exp, OptType, Catch ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.loophole:	AbstractProduction [ Exp, OptType ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.apply:	AbstractProduction [ Exp.rator, Exp.rand, Catch ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.qualifier:	AbstractProduction [ Exp, Qualifier ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.explist:	AbstractProduction [ ExpList ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.prefixop:	AbstractProduction [ PrefixOp, OrderList ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.val:	AbstractProduction [ OrderList ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.all:	AbstractProduction [ OrderList ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.new:	AbstractProduction [ New, TypeExp, Initialization, Catch ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.cons:	AbstractProduction [ Cons, ExpList, Catch ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.listcons:	AbstractProduction [ ListCons, ExpList ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.nil:	AbstractProduction [ ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.typeop:	AbstractProduction [ TypeOp, TypeExp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.size:	AbstractProduction [ TypeExp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.size2:	AbstractProduction [ TypeExp, Exp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.bits:	AbstractProduction [ TypeExp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.bits2:	AbstractProduction [ TypeExp, Exp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.bytes:	AbstractProduction [ TypeExp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.bytes2:	AbstractProduction [ TypeExp, Exp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.units:	AbstractProduction [ TypeExp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.units2:	AbstractProduction [ TypeExp, Exp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.words:	AbstractProduction [ TypeExp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.words2:	AbstractProduction [ TypeExp, Exp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.istype:	AbstractProduction [ Exp, TypeExp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.address:	AbstractProduction [ Exp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.descriptor:	AbstractProduction [ DescList ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.error:	AbstractProduction [ ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
for Exp.transfer:	AbstractProduction [ TransferOp, Exp ]
let IdVal [tree] _ NullId [] where x _ Error ["Expected an Id"];
End;

SaffronScope: Module = Begin
for OptDecList.absent:	AbstractProduction [ ]
let AddDeclarationsToFieldList[tree, fieldList, localContext, cs] _ <
FakeDamageFieldList[fieldList],
FakeDamageContext[localContext]
>
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ 
FakeDamageContext [localContext]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree];

for OptDecList.present:	AbstractProduction [ DecList ]
let AddDeclarationsToFieldList[tree, fieldList, localContext, cs] _ 
AddDeclarationsToFieldList[DecList, fieldList, localContext, cs]
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ 
UpdateLocalContext [DecList, localContext, paintRecords, cs]

let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
HangContextsFromContextTree [DecList, contextTree, rib, paintRecords, cs]
;
for DecList.many:	AbstractProduction [ DecList.head, DecList.tail ]
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ lc1
where lc1 _ FakeDamageContext[localContext]
let AddDeclarationsToFieldList [tree, fl, localContext, cs] _ <fl2, lc2>
where <fl2, lc2> _ AddDeclarationsToFieldList[DecList.tail, fl1, lc1, cs]
where <fl1, lc1> _ AddDeclarationsToFieldList[DecList.head, fl, localContext, cs]

let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
HangContextsFromContextTree [DecList.tail, contextTree1, rib, paintRecords, cs]
where contextTree1 _ HangContextsFromContextTree [DecList.head, contextTree, rib, paintRecords, cs]

;

for DecList.one:	AbstractProduction [ Declaration ]
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ lc1
where lc1 _ FakeDamageContext[localContext]
let AddDeclarationsToFieldList [tree, fl, localContext, cs] _ <fl1, lc1>
where <fl1, lc1> _ AddDeclarationToFieldList[Declaration, fl, localContext, cs]


let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
HangContextsFromContextTree [Declaration, contextTree, rib, paintRecords, cs]
;
for Declaration.opaquetype:	AbstractProduction [ IdentList, Access, OptSize ]
let AddDeclarationToFieldList[tree, fl, localContext, cs] _ AddTypeDeclarationToFieldList[IdentList, fl, lc2, cs, idAccess, typeAccess, tgn, typeExp, default]
where idAccess _ GetAccessVal[Access, GetDefaultAccess[cs]]
where typeAccess _ NullAccessVal[]
where typeExp _ BogusTypeExpPTree[] -- this is okay; there is no such thing as an anonymous opaque type constructor, so this will never be used.  Trust me.
where default _ NullDefaultVal[]
where <lc2, tgn> _ CreateOpaqueTGN [lc1, paint, sizeExp]
where <lc1, paint> _ GetUniquePaint [localContext]
where sizeExp _ GetExpVal [OptSize]

let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;

for Declaration.type:	AbstractProduction [ IdentList, Access.id, Access.type, TypeExp, Default ]
let AddDeclarationToFieldList[tree, fl, localContext, cs] _ AddTypeDeclarationToFieldList[IdentList, fl, lc2, cs, idAccess, typeAccess, tgn, typeExp, default]
where idAccess _ GetAccessVal[Access.id, GetDefaultAccess[cs]]
where typeAccess _ GetAccessVal[Access.type, GetDefaultAccess[cs]]
where typeExp _ TypeExpPTreeVal[TypeExp]
where default _ GetDefaultExpVal [Default]
where <lc2, tgn> _ MakeType [TypeExp, lc1, paintRecords, cs] 
where paintRecords _ True[] -- this is a crock!
where <lc1, paint> _ GetUniquePaint [localContext]

let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;

for Declaration.value:	AbstractProduction [ IdentList, Access, Entry, ReadOnly, TypeExp, Initialization ]
let AddDeclarationToFieldList[tree, fl, localContext, cs] _ <fl1, lc1>
where fl1 _ AddValueDeclarationToFieldList[IdentList, fl, cs, parseTree, access, tgn, init]
where parseTree _ DeclarationPTreeVal[tree]
where init _ InitializationPTreeVal[Initialization]
where access _ GetAccessVal[Access, GetDefaultAccess[cs]]
where <lc1, tgn> _ MakeType [TypeExp, localContext, paintRecords, cs] 
where paintRecords _ True[] -- this is a crock!

let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for IdentList.many: 			AbstractProduction [IdentList.head, IdentList.tail]
let AddValueDeclarationToFieldList[tree, fl, cs, parseTree, access, tgn, init] _ fl2
where fl2 _ AddValueDeclarationToFieldList[IdentList.tail, fl1, cs, parseTree, access, tgn, init]
where fl1 _ AddValueDeclarationToFieldList[IdentList.head, fl, cs, parseTree, access, tgn, init]
let AddTypeDeclarationToFieldList[tree, fl, lc, cs, idAccess, typeAccess, tgn, typeExp, default] _ <fl2, lc2>
where <fl2, lc2> _ AddTypeDeclarationToFieldList[IdentList.tail, fl1, lc1, cs, idAccess, typeAccess, tgn, typeExp, default]
where <fl1, lc1> _ AddTypeDeclarationToFieldList[IdentList.head, fl, lc, cs, idAccess, typeAccess, tgn, typeExp, default]
;

for IdentList.one:		AbstractProduction [Ident]
let AddValueDeclarationToFieldList[tree, fl, cs, access, parseTree, tgn, init] _ 
AddValueDeclarationToFieldList[Ident, fl, cs, access, parseTree, tgn, init]
let AddTypeDeclarationToFieldList[tree, fl, lc, cs, idAccess, typeAccess, tgn, typeExp, default] _ 
AddTypeDeclarationToFieldList[Ident, fl, lc, cs, idAccess, typeAccess, tgn, typeExp, default]
;

for Ident.id:		AbstractProduction [Id]
let AddValueDeclarationToFieldList[tree, fl, cs, parseTree, access, tgn, init] _ fl1
where fl1 _ AppendFieldToFieldList[fl, field]
where field _ if InitializationIsBinding[InitializationVal[init]]
then CreateConstantField[Id, position, parseTree, access, tgn, init]
else CreateVariableField[Id, position, parseTree, access, tgn, init]
where position _ NullPosition[]
let AddTypeDeclarationToFieldList[tree, fl, lc, cs, idAccess, typeAccess, tgn, typeExp, default] _ <fl1, lc1>
where fl1 _ AppendFieldToFieldList[fl, field]
where field _ CreateNamedTypeField[Id, position, idAccess, namedTGN, typeExp]
where <lc1, namedTGN> _ CreateNamedTGN[lc, Id, position, typeAccess, tgn, default]
where position _ NullPosition[]
;

for Ident.idposition:	AbstractProduction [Id, Position]
let AddValueDeclarationToFieldList[tree, fl, cs, parseTree, access, tgn, init] _ fl1
where fl1 _ AppendFieldToFieldList[fl, field]
where field _ if InitializationIsBinding[InitializationVal[init]]
then CreateConstantField[Id, position, parseTree, access, tgn, init]
else CreateVariableField[Id, position, parseTree, access, tgn, init]
where position _ GetPositionVal[Position]
let AddTypeDeclarationToFieldList[tree, fl, lc, cs, idAccess, typeAccess, tgn, typeExp, default] _ <fl1, lc1>
where fl1 _ AppendFieldToFieldList[fl, field]
where field _ CreateNamedTypeField[Id, position, idAccess, namedTGN, typeExp]
where <lc1, namedTGN> _ CreateNamedTGN[lc, Id, position, typeAccess, tgn, default]
where position _ GetPositionVal[Position]
;

for OptSize.absent:	AbstractProduction [ ]
let GetExpVal [tree] _ MakeUnparsedNullValue []
;
for OptSize.present:	AbstractProduction [ Exp ]
let GetExpVal [tree] _ MakeUnparsedValue [Exp]
;

for StatementList.empty:	AbstractProduction [ ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;

for StatementList.more:	AbstractProduction [ StatementList, Statement ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
HangContextsFromContextTree [Statement, contextTree1, rib, paintRecords, cs]
where contextTree1 _ 
HangContextsFromContextTree [StatementList, contextTree, rib, paintRecords, cs]
;
for Statement.ifthen:	AbstractProduction [ Exp, Statement ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
HangContextsFromContextTree [Statement, contextTree, rib, paintRecords, cs]
;
for Statement.ifthenelse:	AbstractProduction [ Exp, Statement.thenpart, Statement.elsepart ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
HangContextsFromContextTree [Statement.elsepart, contextTree1, rib, paintRecords, cs]
where contextTree1 _ 
HangContextsFromContextTree [Statement.thenpart, contextTree, rib, paintRecords, cs]
;
for Statement.select:	AbstractProduction [ SelectHead, SelectStmtList, OptStatement ] 
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.exp:	AbstractProduction [ Exp ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;

for Statement.assign:	AbstractProduction [ Exp.lhs, Exp.rhs ] 
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.multiassign:	AbstractProduction [ ExpList, Exp ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.block:	AbstractProduction [ Checked, Block ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
HangContextsFromContextTree [Block, contextTree, rib, paintRecords, cs]
;
for Statement.loopcontrol:	AbstractProduction [ ForClause, DoTest, Scope, DoExit ]
 
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;

for Statement.exit:	AbstractProduction [ ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.loop:	AbstractProduction [ ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.goto:	AbstractProduction [ Id ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.return:	AbstractProduction [ OptArgs ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.transfer:	AbstractProduction [ Transfer, Exp ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.free:	AbstractProduction [ Free, Exp, Catch ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.wait:	AbstractProduction [ Exp ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.error:	AbstractProduction [ ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.stop:	AbstractProduction [ ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.null:	AbstractProduction [ ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.resume:	AbstractProduction [ OptArgs ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.reject:	AbstractProduction [ ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.continue:	AbstractProduction [ ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.retry:	AbstractProduction [ ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.getstate:	AbstractProduction [ Exp ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;
for Statement.setstate:	AbstractProduction [ Exp ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
FakeDamageContextTree [contextTree]
;



for Block:	AbstractProduction [ Scope, ExitList ]
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _ 
FakeDamageContextTree[contextTree]
where err _ Error["should not be here"]
let MakeContextTree[tree, parentRib, paintRecords, cs] _ EmptyContextTree[parentRib]
where err _ Error["should not be here"]
;

for IdOrString.id: 	AbstractProduction [Id]
let RopeFromIdOrString[tree] _ RopeFromId[Id];

for IdOrString.string: 	AbstractProduction [String]
let RopeFromIdOrString[tree] _ RopeFromString[String];

End.


���<’��SaffronMethods.ThreeC4 (July 16, 1987 4:02:51 pm PDT)
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Lucy Hederman August 20, 1987 3:49:01 pm PDT
Sturgis, July 21, 1987 3:16:17 pm PDT
James Rauen, June 18, 1988 12:27:04 pm PDT
replaced FreezeLocalContext[foo] with FreezeLocalContext[AnalyzeDependencies[foo]]
Last edited by: James Rauen August 18, 1988 1:20:23 am PDT


RecList
ParameterList
VariantList
VariantItem
IdList
let AddIdsToInterfaceTGN [tree, localContext, interfaceTGN, interface] _
    AddTGNToInterfaceTGN [localContext1, interfaceTGN, Id, accessVal, linkTgn]
where <localContext1, linkTgn> _ CreateLinkTGN [localContext, entryTgn, interface, Id]
entryTgn is NIL if the Id is for an entry point rather than a type.
Until we know about entry points we can't handle this correctly
where <accessVal, entryTgn> _ LookupInterfaceEntry [interface, Id]
let AddIdsToInterfaceTGN [tree, localContext, interfaceTGN, interface] _
	 AddIdsToInterfaceTGN [IdList, localContext2, interfaceTGN, interface]
where localContext2 _ 
AddTGNToInterfaceTGN [localContext1, interfaceTGN, Id, accessVal, linkTgn]
where <localContext1, linkTgn> _ CreateLinkTGN [localContext, entryTgn, interface, Id]
where <accessVal, entryTgn> _ LookupInterfaceEntry [interface, Id]
verify that entryTgn is as intended
Tag
TagType
TypeList
TypeItem
PairList
PairItem
Access
IdentList
let AddNamedFieldsToFieldList [tree, templateField, fieldList] _ fl2
where fl2 _ AddNamedFieldsToFieldList [IdentList.tail, templateField, fl1]
where fl1 _ AddNamedFieldsToFieldList [IdentList.head, templateField, fieldList]
let PutNewTypeNamesInLocalContext[tree, localContext, accessVal]_
PutNewTypeNamesInLocalContext[IdentList.tail, localContext1, accessVal]
where localContext1 _
PutNewTypeNamesInLocalContext[IdentList.head, localContext, accessVal]
let PutNewVariableNamesInLocalContext[tree, localContext, accessVal, constant]_
PutNewVariableNamesInLocalContext[IdentList.tail, localContext1, accessVal, constant]
where localContext1 _
PutNewVariableNamesInLocalContext[IdentList.head, localContext, accessVal, constant]
let RecAddArcsfromLVTGNtoTGN[tree, localContext, accessVal, tgn, defaultExp]_
RecAddArcsfromLVTGNtoTGN[IdentList.tail, localContext1, accessVal, tgn, defaultExp]
where localContext1 _ RecAddArcsfromLVTGNtoTGN[IdentList.head, localContext, accessVal, tgn, defaultExp]
let RecAddArcsFromLocalNameToInstance[tree, localContext, accessVal, instance]_
RecAddArcsFromLocalNameToInstance[IdentList.tail, localContext1, accessVal, instance]
where localContext1 _ RecAddArcsFromLocalNameToInstance[IdentList.head, localContext, accessVal, instance]
let AddNamedFieldsToFieldList [tree, templateField, fieldList] _ fl1
where fl1 _ AddNamedFieldsToFieldList [Ident, templateField, fieldList]
let PutNewTypeNamesInLocalContext[tree, localContext, accessVal] _
 PutNewTypeNamesInLocalContext[Ident, localContext, accessVal]
let PutNewVariableNamesInLocalContext[tree, localContext, accessVal, constant] _
 PutNewVariableNamesInLocalContext[Ident, localContext, accessVal, constant]
let RecAddArcsfromLVTGNtoTGN[tree, localContext, accessVal, tgn, defaultExp] _
 RecAddArcsfromLVTGNtoTGN[Ident, localContext, accessVal, tgn, defaultExp]
let RecAddArcsFromLocalNameToInstance[tree, localContext, accessVal, instance] _
 RecAddArcsFromLocalNameToInstance[Ident, localContext, accessVal, instance]
Ident
let AddNamedFieldsToFieldList [tree, templateField, fieldList] _ fl1
where fl1 _ AppendFieldToFieldList[fieldList, field]
where field _ RenameField[templateField, Id]
let PutNewTypeNamesInLocalContext[tree, localContext, accessVal] _ localContext1
where <localContext1, tgn> _ CreateLocallyVisibleTGN [localContext, Id, accessVal ]

let PutNewVariableNamesInLocalContext[tree, localContext, accessVal, constant] _ localContext1
where localContext1 _ AddVariableName[localContext, Id, accessVal, constant]

let RecAddArcsfromLVTGNtoTGN[tree, localContext, accessVal, tgn, defaultExp] _
 AddArcFromLVTGNToTGN [localContext, lvtgn, accessVal, tgn, defaultExp]
where lvtgn _ LookupTypeNameInLocalContext [localContext, Id]
let RecAddArcsFromLocalNameToInstance[tree, localContext, accessVal, instance] _
 AddArcFromLocalNameToInstance [localContext, Id, accessVal, instance]
let AddNamedFieldsToFieldList [tree, templateField, fieldList] _ fl1
where fl1 _ AppendFieldToFieldList[fieldList, field]
where field _ RenameField[templateField, Id]
it would be nice to pass Position to RenameField....
let PutNewTypeNamesInLocalContext[tree, localContext, accessVal] _ localContext1
where <localContext1, tgn> _ CreateLocallyVisibleTGN [localContext, Id, accessVal ]

let PutNewVariableNamesInLocalContext[tree, localContext, accessVal, constant] _ localContext1
where localContext1 _ AddVariableName[localContext, Id, accessVal, constant]

let RecAddArcsfromLVTGNtoTGN[tree, localContext, accessVal, tgn, defaultExp] _
 AddArcFromLVTGNToTGN [localContext, lvtgn, accessVal, tgn, defaultExp]
where lvtgn _ LookupTypeNameInLocalContext [localContext, Id]
let RecAddArcsFromLocalNameToInstance[tree, localContext, accessVal, instance] _
 AddArcFromLocalNameToInstance [localContext, Id, accessVal, instance]
Position
OptBits
ElementList
Element
Exp
Scope
Look carefully at this. The syntax does not match the nesting semantics. 
for Scope:	AbstractProduction [ BindList, Catch, OptDecList, StatementList ]
let MakeContextTree [tree, rib, paintRecords, cs] _
Make the contextTree for the entire scope, nesting everything else inside the bindlist's context.
MakeBindListContextTreeWithScope [BindList, scopePTree, rib, paintRecords, cs]
where scopePTree _ ScopePTreeVal [tree]
let MakeContextTree1 [tree, rib, paintRecords, cs] _
Make the contextTree for the context nested within the BindList.
 HangContextsFromContextTree [StatementList,  decListContextTree, newRib, paintRecords, cs]
where decListContextTree _ HangContextsFromContextTree [OptDecList, thisScopeContextTree, newRib, paintRecords, cs]
where thisScopeContextTree _ EmptyContextTree [newRib]
(process statements here?  this will probably require a nested context for newly constructed types, but they can never be circular)
where newRib _ FreezeLocalContext[thisScopeLocalContext]
(note: Freeze will "process" the type graph, looking for cycles etc.)
where thisScopeLocalContext _ UpdateLocalContext [OptDecList, localContext, paintRecords, cs]
where localContext _ CreateEmptyContext [rib, False[]]
;
ignoring Catch in Scope 
BindList
for BindList.empty:	AbstractProduction [ ]
let MakeBindListContextTreeWithDefBody [tree, defBodyPTree, rib, paintRecords, cs] _
MakeContextTree1 [defBody, rib, paintRecords, cs]
where defBody _ DefBodyVal [defBodyPTree]
avoids making an unnecessary context tree node
let MakeBindListContextTreeWithScope [tree, scopePTree, rib, paintRecords, cs] _
MakeContextTree1 [scope, rib, paintRecords, cs]
where scope _ ScopeVal [scopePTree]
avoids making an unnecessary context tree node
let UpdateLocalContext [tree, localContext, paintRecords, cs] _
FakeDamageContext [localContext]
;
for BindList.more:	AbstractProduction [ BindList, BindItem ]
Semantically the scope creates a subcontext (contextTree2) of the Bindlist.
Rib2 is the rib corresponding to the context of Bindlist.
let MakeBindListContextTreeWithDefBody [tree, defBodyPTree, rib, paintRecords, cs] _ 
	AddSubContextTree [EmptyContextTree [rib2], contextTree2]
where contextTree2 _ MakeContextTree1[defBody, rib2, paintRecords, cs]
where defBody _ DefBodyVal [defBodyPTree]
where rib2 _ FreezeLocalContext[bindListsLocalContext]
where bindListsLocalContext _ UpdateLocalContext [tree, localContext, paintRecords, cs]
where localContext _ CreateEmptyContext [rib, False[]]

let MakeBindListContextTreeWithScope [tree, scopePTree, rib, paintRecords, cs] _ 
	AddSubContextTree [EmptyContextTree [rib2], contextTree2]
where contextTree2 _ MakeContextTree1[scope, rib2, paintRecords, cs]
where scope _ ScopeVal [scopePTree]
where rib2 _ FreezeLocalContext[bindListsLocalContext]
where bindListsLocalContext _ UpdateLocalContext [tree, localContext, paintRecords, cs]
where localContext _ CreateEmptyContext [rib, False[]]

let UpdateLocalContext [tree, localContext, paintRecords, cs] _
UpdateLocalContext [BindItem, localContext1, paintRecords, cs]
where localContext1 _ UpdateLocalContext [BindList, localContext, paintRecords, cs]
;
BindItem
for BindItem.named:	AbstractProduction [ Id, Exp ]
let UpdateLocalContext [tree, localContext, paintRecords, cs] _
RenameInterface [localContext, Id, interfaceTgn]
where interfaceTgn _ LookupTypeNameInLocalContext [localContext, IdVal [Exp]]
;
for BindItem.unnamed:	AbstractProduction [ Exp ]
let UpdateLocalContext [tree, localContext, paintRecords, cs] _
OpenInterface [localContext, interfaceTgn]
where interfaceTgn _ LookupTypeNameInLocalContext [localContext, IdVal [Exp]]
;
OptDecList
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ localContext2
where localContext2 _ stuff fl into wherever.
where localContext2 _ localContext1
where <fl, localContext1> _ MakeFieldListFromDecList[DecList, localContext, cs]
for OptDecList.present:	AbstractProduction [ DecList ]
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ 
FillInLocalContext [DecList, localContext1, paintRecords, cs]
where localContext1 _ PutNewNamesInLocalContext [DecList, localContext, cs]

let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _
HangContextsFromContextTree [DecList, contextTree, rib, paintRecords, cs]
;
DecList
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ lc3
where lc3 _ AddDeclarationsToLocalContext[fl2, lc2, cs]
where <fl2, lc2> _ AddDeclarationsToFieldList[tree, fl1, localContext, cs]
where fl1 _ CreateEmptyFieldList[]
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ lc1
where lc1 _ CompileDecList[tree, localContext, cs]
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ 
FillInLocalContext [tree, localContext1, paintRecords, cs]
where localContext1 _ PutNewNamesInLocalContext [tree, localContext, cs]
let PutNewNamesInLocalContext [tree, localContext, cs] _ 
PutNewNamesInLocalContext [DecList.tail, localContext1, cs]
where localContext1 _ PutNewNamesInLocalContext [DecList.head, localContext, cs] 

let FillInLocalContext [tree, localContext, paintRecords, cs] _ 
FillInLocalContext [DecList.tail, localContext1, paintRecords, cs]
where localContext1 _ FillInLocalContext [DecList.head, localContext, paintRecords, cs]
where lc1 _ CompileDecList[tree, localContext, cs]
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ lc3
where lc3 _ AddDeclarationsToLocalContext[fl2, lc2, cs]
where <fl2, lc2> _ AddDeclarationsToFieldList[tree, fl1, localContext, cs]
where fl1 _ CreateEmptyFieldList[]
let UpdateLocalContext [tree, localContext, paintRecords, cs] _ 
FillInLocalContext [tree, localContext1, paintRecords, cs]
where localContext1 _ PutNewNamesInLocalContext [tree, localContext, cs]
let PutNewNamesInLocalContext[tree, localContext, cs] _
PutNewNamesInLocalContext[Declaration, localContext, cs]

let FillInLocalContext[tree, localContext, paintRecords, cs] _
FillInLocalContext[Declaration, localContext, paintRecords, cs]
Declaration
let AddDeclarationToFieldList[tree, fl, localContext, cs] _ <fl1, lc3>
where fl1 _ AddNamedFieldsToFieldList[IdentList, templateField, fl]
where templateField _ CreateNamedTypeField[name1, position1, access1, namedTGN]
where name1 _ IdFromRope["(Fill me in)"]
where position1 _ NullPosition[]
where access1 _ GetAccessVal[Access, GetDefaultAccess[cs]]
where <lc3, namedTGN> _ CreateNamedTGN[lc2, name, position, access, tgn, default]
where name _ IdFromRope["(Named TGN)"]
where position _ NullPosition[]
where access _ NullAccessVal[]
where default _ NullDefaultVal[]
where <lc2, tgn> _ CreateOpaqueTGN [localContext1, paint, sizeExp]
where <localContext1, paint> _ GetUniquePaint [localContext]
where sizeExp _ GetExpVal [OptSize]

let PutNewNamesInLocalContext[tree, localContext, cs]  _
 PutNewTypeNamesInLocalContext[IdentList, localContext, GetAccessVal[Access, GetDefaultAccess[cs]]]
let FillInLocalContext[tree, localContext, paintRecords, cs] _
RecAddArcsfromLVTGNtoTGN [IdentList, localContext2, NullAccessVal [], tgn, NullDefaultVal []]
where <localContext2, tgn> _ CreateOpaqueTGN [localContext1, paint, sizeExp]
where <localContext1, paint> _ GetUniquePaint [localContext]
where sizeExp _ GetExpVal [OptSize]
ignoring optsize
let AddDeclarationToFieldList[tree, fl, localContext, cs] _ <fl1, lc3>
where fl1 _ AddNamedFieldsToFieldList[IdentList, templateField, fl]
where templateField _ CreateNamedTypeField[name1, position1, access1, namedTGN]
where name1 _ IdFromRope["(Fill me in)"]
where position1 _ NullPosition[]
where access1 _ GetAccessVal[Access.id, GetDefaultAccess[cs]]
where <lc3, namedTGN> _ CreateNamedTGN[lc2, name, position, access, tgn, default]
where name _ IdFromRope["(Named TGN)"]
where position _ NullPosition[]
where access _ GetAccessVal[Access.type, GetDefaultAccess[cs]]
where default _ GetDefaultExpVal [Default]
where <lc2, tgn> _ MakeType [TypeExp, localContext1, paintRecords, cs] 
where paintRecords _ True[] -- this is a crock!
where <localContext1, paint> _ GetUniquePaint [localContext]

let PutNewNamesInLocalContext[tree, localContext, cs]  _
 PutNewTypeNamesInLocalContext[IdentList, localContext, GetAccessVal[Access.id, GetDefaultAccess[cs]]]
let FillInLocalContext[tree, localContext, paintRecords, cs] _
RecAddArcsfromLVTGNtoTGN [IdentList, localContext1, GetAccessVal[Access.type, GetDefaultAccess[cs]], tgn, defaultExp]
where <localContext1, tgn> _ MakeType [TypeExp, localContext,  paintRecords, cs]
where defaultExp _ GetDefaultExpVal [Default]
let AddDeclarationToFieldList[tree, fl, localContext, cs] _ <fl1, lc2>
where fl1 _ AddNamedFieldsToFieldList[IdentList, templateField, fl]
where templateField _ if InitializationIsBinding[Initialization]
then CreateConstantField[name, position, access, tgn, value]
else CreateVariableField[name, position, access, tgn, value]
where name _ IdFromRope["(Fill me in)"]
where position _ NullPosition[]
where access _ GetAccessVal[Access, GetDefaultAccess[cs]]
where <value, lc2> _ GetInitialValue[Initialization, tgn, lc1, cs]
where <lc1, tgn> _ MakeType [TypeExp, localContext, paintRecords, cs] 
where paintRecords _ True[] -- this is a crock!

let PutNewNamesInLocalContext[tree, localContext, cs] _  PutNewVariableNamesInLocalContext[IdentList, localContext, GetAccessVal[Access, GetDefaultAccess[cs]], GetBooleanVal[ReadOnly]]

so far, we're only evaluating the initialization expressions...
let FillInLocalContext[tree, localContext, paintRecords, cs] _ RecAddArcsFromLocalNameToInstance[IdentList, localContext2, GetAccessVal[Access, GetDefaultAccess[cs]], initializationInstance]
where <initializationInstance, localContext2> _ 
GetInitialValue[Initialization, tgn, localContext1, cs]
where <localContext1, tgn> _ MakeType [TypeExp, localContext,  paintRecords, cs]

ignoring value declarations

OptSize
StatementList
Statement
can exp change context tree ?

can exp change context tree ?
ignoring Checked on a block statement
Block
let HangContextsFromContextTree [tree, contextTree, rib, paintRecords, cs] _ 
AddSubContextTree[contextTree, subContextTree]
where subContextTree _ MakeContextTree [Scope, rib, paintRecords, cs]
let MakeContextTree[tree, parentRib, paintRecords, cs] _ MakeContextTree[Scope, parentRib, paintRecords, cs]
ignoring ExitList
eof...

Ê-��˜�codešœ5™5K™;K™,K™%™*KšœR™R—K™:—K™�JšÐizœ1˜8K™�šÐbnœœ˜$headšÐbz™šœÏb
œœ˜*Kšœu˜xK˜—šœ œœ
˜6šœR˜UKšœk˜pKšœ'˜,—K˜—šœ œœ
˜5šœR˜UKšœe˜jKšœ'˜,—K˜——šÐnz
™
codetabš œœ˜/Kšœu˜xMšœ˜—š œœ˜-Mšœr˜uMšœ˜—š œœ
˜;šœR˜UKšœk˜pKšœ'˜,—Mšœ˜—š œœ
˜;šœR˜UKšœe˜jKšœ'˜,—Mšœ˜——šŸ™šœ œœ˜7šœ‹˜ŽKšœ'˜,—Kšœœ˜Ÿšœ<˜?KšœO˜TKšœG˜L—Kšœw˜zK˜—š œœ˜Ešœ‰˜ŒKšœp˜uKšœ'˜,—K˜�šœž˜¡Kšœn˜s—šœ<˜?KšœP˜UKšœP˜UKšœG˜L—šœx˜{KšœP˜U—Kš˜——š¡™šœÏnœœ˜7šœŠ˜Kšœ"˜'KšœV˜[—Kšœr˜uKšœ˜——šŸ™šœ 
œœ˜)KšœT˜WKšœ…˜ˆK˜RšœE™HKšœN™NKšœQ™VK™CK™?Kšœ=™B—Kšœ˜—šœ œœ˜2šœ[˜^Kšœ9˜9—šœs˜vKšœ\˜a—šœ*˜-Kšœ-˜2Kšœ'˜,—šœE™HKšœG™Gšœ™KšœJ™J—KšœQ™VKšœ=™BK™#—K˜——šÏz™šœ 	œœ˜<šœ9˜<Kšœ˜Kšœ,˜,—Kšœm˜pKšœd˜gKšœ˜—š 
œœ˜0Kšœ=˜@Kšœm˜pKšœW˜ZKšœ˜—š 
œœ˜0Kšœ>˜AKšœm˜pšœW˜ZKšœ*˜/—Kšœ˜K˜�——šŸ™šœ œœ˜(šœ_˜bKšœ1˜6—K˜—šœ œœ˜3Kšœu˜xK˜——K˜K˜�—š œ˜%šŸ™šœ 
œœ!˜Fšœ‘˜”Kšœj˜o—K˜—šœ œœ
˜1Kšœ‹˜ŽK˜—K˜�—šŸ™K˜�Kšœ¢œœ˜5˜�šœ_˜bKšœ8˜=Kšœ-˜2KšœJ˜OKšœ(˜-———˜K˜�——š œ˜*šŸ™K˜�šœ 
œœ!˜Fšœš˜Kšœn˜s—K˜—K˜�šœ œœ
˜1Kšœ’˜•K˜—K˜�—šŸ™K˜�šœžœœ(˜Hšœ¢˜¥KšœJ˜OKšœ8˜=Kšœ(˜-—K˜——šŸ™šœ œœ˜)Kšœ;˜>—šœ 
œœ˜*Kšœ:˜=—šœ œœ˜*Kšœ;˜>—K˜�—˜K˜�——š œ˜*šŸ	™	šœ œœ#˜Išœ‘˜”KšœY˜^—šœA™DKšœE™JKšœK™P—šœ†™‰KšœW™\—šœ¢™¥Kšœe™j—šœž™¡Kšœc™h—šœ¢™¥Kšœe™j—šœM˜PKšœB˜GKšœ$˜)—šœ`˜cKšœB˜G—K˜—K˜�šœ 
œœ
˜/Kšœ‡˜ŠšœA™DKšœB™G—Kšœ~™Kšœš™Kšœ–™™Kšœš™šœC˜FKšœ$˜)—KšœV˜YK˜——šŸ™šœ œœ˜'šœn˜qKšœK˜P—šœA™DKšœ/™4Kšœ'™,—šœM™PKšœN™SK™�—šœ[™^KšœG™LK™�—šœ“™–Kšœ8™=—Kšœ”™—Kšœ,˜/KšœX˜[K˜K˜�—šœ œœ˜9šœo˜rKšœU˜Z—šœA™DKšœ/™4Kšœ'™,Kšœ4™4—šœM™PKšœN™SK™�—šœ[™^KšœG™LK™�—šœ“™–Kšœ8™=—Kšœ”™—Kšœ6˜9šœX˜[Kšœ;˜@—K˜——šŸ™šœ¢œœ˜1šœL˜OKšœ#˜(—K˜——š¡™šœ œœ˜*Kšœ$˜'K˜—šœ œœ˜2šœI˜LK˜———K˜K˜�—š œ˜&šŸ™šœ œœ˜-Kšœq˜tK˜K˜�—šœ œœ˜AšœN˜QKšœS˜XKšœU˜ZKšœ+˜0—K˜�—K˜�—K˜K˜�—š¢œ˜"šÑbiz™šœ 
œœ˜)Kšœ3˜6Kšœ˜K˜�—šœ œœ˜5Kšœ3˜6Kšœ˜K˜�—šœ œœ˜4Kšœ:˜=K˜——š¤™š œœ˜%Kšœ˜Kšœ˜—š œœ˜>Kšœœ˜@—š 
œœ˜3Kšœœ˜@—š œœ ˜CKšœœ˜@—š œœ˜6Kšœœ˜@—š œœ˜7Kšœœ˜@—š œœ˜'Kšœœ˜@—š 
œœ˜6Kšœœ˜@—š œœ)˜OKšœœ˜@—š œœ+˜MKšœœ˜@—š œœ˜7Kšœœ˜@—š œœ˜8Kšœœ˜@—š œœ˜'Kšœœ˜@—š œœ˜-Kšœœ˜@—š 
œœ
˜+Kšœœ˜@—š 	œœ	˜)Kšœœ˜@—š 	œœ	˜)Kšœœ˜@—š œœ˜:Kšœœ˜@—š 
œœ˜5Kšœœ˜@—š 
œœ˜@Kšœœ˜@—š œœ˜8Kšœœ˜@—š œœ˜/Kšœœ˜@—š 
œœ˜<Kšœœ˜@—š œœ˜-Kšœœ˜@—š œœ˜-Kšœœ˜@—š œœ(˜GKšœœ˜@—š 	œœ˜9Kšœœ˜@—š 
œœ˜:Kšœœ˜@—š œœ˜#Kšœœ˜@—š œœ˜6Kšœœ˜@—š 	œœ˜,Kšœœ˜@—š 
œœ˜2Kšœœ˜@—š 	œœ˜,Kšœœ˜@—š 
œœ˜2Kšœœ˜@—š 
œœ˜-Kšœœ˜@—š œœ˜3Kšœœ˜@—š 
œœ˜-Kšœœ˜@—š œœ˜3Kšœœ˜@—š 
œœ˜-Kšœœ˜@—š œœ˜3Kšœœ˜@—š œœ˜3Kšœœ˜@—š œœ˜+Kšœœ˜@—š œœ
˜3Kšœœ˜@—š 
œœ˜%Kšœœ˜@—š 
œœ˜8Kšœœ˜@——˜K˜�——š¢œ˜š¤™M™Išœ¢œœ/™LKšœ0™3™ašœN™NKšœ"™'——Kšœ1™4™@Kšœ[™[Kšœn™sšœ1™6K™ƒ—šœ3™8K™E—KšœX™]Kšœ1™6—Kšœ™Kšœ™——š£™š œœ™*šœQ™TMšœ1™1Mšœ$™)M™.—šœM™PMšœ/™/Mšœ™#M™.—šœ<™?Mšœ ™ —Mšœ™—Mš œœ™<MšœK™K™9šœR™UKšœ:™:šœA™FMšœ$™)—Kš£œ1™6KšœR™WKšœ1™6K™�—šœN™QKšœ:™:šœ?™DMšœ™#—Kš£œ1™6KšœR™WKšœ1™6—K™�šœ<™?Kšœ>™>KšœN™S—K™——š™šœ œœ™2šœ<™?Kšœ0™0KšœH™M—Mšœ™—šœ œœ™0šœ<™?Kšœ*™*KšœH™M—Mšœ™——š
™
šœ œœ˜-šœE˜EM˜Mšœ˜M˜—Kšœ^˜aKšœn˜qK˜�—šœ œœ˜6šœD˜DMšœ@˜@—šœ@˜@Mšœ<˜<—šœJ™MK™-Kšœ™#KšœJ™O—K˜�Kšœ“˜–Kšœ˜—šœ œœ™6šœ{™~KšœF™K—K™�Kšœ“™–Kšœ™——š™šœ œœ˜Cšœ@™CMšœ7™7MšœJ™JMšœ™"—šœ@˜CMšœ+˜+—šœ@™CMšœ2™2—šœE˜HMšœD˜IMšœL˜Q—šœx™{KšœC™H—šœr™uKšœL™QK™�—šœ€™ƒKšœR™W—K˜�šœ™˜œKšœ^˜c—K˜�Kšœ˜K˜�—šœ œœ˜3šœ@˜CMšœ+˜+Mšœ2™2—šœ@™CMšœ7™7MšœJ™JMšœ™"—šœE˜HMšœJ˜O—M˜�šœx™{KšœC™H—šœ4™7Kšœ8™8K™�—šœ;™>Kšœ?™?—K˜�Kšœ—˜šKšœ˜——š™šœ œœ˜Mšœ›˜žMšœ;˜;Mšœ"˜"Mšœ$Ïcw˜›Mšœ ˜ Kšœ3˜8Kšœ-˜2Kšœ˜#K˜�—šœC™FMšœ>™CMšœJ™OMšœ#™(Mšœ™ Mšœ5™:MšœL™QMšœ!™&Mšœ™Mšœ™Mšœ™ Kšœ=™BKšœ7™<Kšœ™#M™�—Kšœ™™œšœ™™œKšœG™LKšœ7™<Kšœ™#—Kšœm˜pJšœ˜J™K˜�—šœ œœ8˜`šœ›˜žMšœ9˜>Mšœ=˜BM˜(Mšœ%˜*Kšœ8˜=Kšœ¥˜/Kšœ-˜2M˜�—šœC™FMšœ>™CMšœJ™OMšœ#™(Mšœ™ Mšœ8™=MšœL™QMšœ!™&Mšœ™Mšœ9™>Mšœ%™*KšœB™GKšœ¥™/Kšœ7™<M™�—Kšœœ™Ÿšœ±™´KšœK™PKšœ(™-—Kšœm˜pKšœ˜—M˜�šœ œœ@˜išœC˜FMšœ[˜[Mšœ+˜+Mšœ3˜3Mšœ4˜9KšœA˜FKšœ¥˜/K˜�—šœC™FMšœ>™Cšœœ(™@Mšœ8™<Mšœ8™<—Mšœ"™'Mšœ™Mšœ4™9Mšœ=™BKšœA™FKšœ¥™/K™�—Kšœµ™¸K™�K™?šœ»™¾šœ+™0Kšœ7™7—KšœK™PK™�—Kšœm˜pJšœ˜J™J™�—šœ¢œœ!˜JšœQ˜TJšœ\˜aJšœ[˜`—šœj˜mJšœv˜{Jšœt˜y—J˜J˜�—šœž
œœ˜.šœN˜QKšœK˜K—šœ`˜cJšœ]˜]—J˜J˜�—šœžœœ˜&šœQ˜TKšœ(˜-šœ	œ1˜AKšœ@˜DKšœ@˜D—Kšœ˜—šœj˜mKšœ(˜-KšœH˜MKšœM˜RKšœ˜—˜K˜�——šœžœœ˜7šœQ˜TKšœ(˜-šœ	œ1˜AKšœ@˜DKšœ@˜D—Kšœ$˜)—šœj˜mKšœ(˜-KšœH˜MKšœM˜RKšœ$˜)—K˜—J˜�—š™š œœ˜*Mšœ,˜/Mšœ˜—š œœ˜/Mšœ+˜.Mšœ˜—L˜�—šÑinz
™
šœ œœ˜/Kšœm˜pKšœ˜K˜�—šœ œœ˜Gšœ–˜™Kšœ`˜e—Kš˜——š¦	™	šœ œœ˜;Kšœ•˜˜Kšœ˜—K™K™�šœ œœ0˜\šœŸ˜¢Kšœe˜j—Kš˜—šœ œœ.˜VKšœm˜pKš˜—šœ 
œœ˜-Kšœm˜pKš˜—K™K˜�šœ œœ˜>Kšœm˜pKš˜—šœ œœ˜>Kšœm˜pKš˜—šœ œœ˜:Kšœ‘˜”Kš˜Kšœ%™%—Kšœ œœ%˜Ršœ˜Kšœm˜pKš˜—K˜�šœ œœ˜*Kšœm˜pKš˜—šœ œœ˜*Kšœm˜pKš˜—šœ œœ˜-Kšœm˜pKš˜—šœ œœ˜4Kšœm˜pKš˜—šœ œœ˜<Kšœm˜pKš˜—šœ œœ˜;Kšœm˜pKš˜—šœ œœ˜.Kšœm˜pKš˜—šœ œœ˜+Kšœm˜pKš˜—šœ œœ˜*Kšœm˜pKš˜—šœ œœ˜*Kšœm˜pKš˜—šœ œœ˜4Kšœm˜pKš˜—šœ œœ˜,Kšœm˜pKš˜—šœ œœ˜.Kšœm˜pKš˜—šœ œœ˜+Kšœm˜pKš˜—šœ œœ˜2Kšœm˜pKš˜—šœ œœ˜2Kšœm˜pKš˜—K˜�K˜�K˜�—š¦™šœ¢œœ˜1šœm˜pK˜'—šœT˜TK˜'—šœy™|Kšœ@™E—Kšœl™lKšœ˜Kšœ™K˜�——šœ¢
œœ˜+Kšœ+˜.K˜�—šœ¢œœ	˜3Kšœ3˜6—K˜�K˜K˜�—K˜�K™K™�—�…—����tÞ��ϝ��