Constructs & Concepts

Constructs & Concepts

Constructs & Concepts Language Design for Flexibility and Reliability Anya Helene Bagge moduleCppSkinhiddenscontext-freestart-symbolsProgramimportsDeclarationsexportssortsTmplClauseClassClausecontext-freesyntaxTmplClauseDecl->Decl cons("TmplDecl") "template""<" TypeParam"," *">"RequiresClause*->TmplClause cons("Template") "requires"Identifier"<" ConceptArgument"," *">"->RequiresClause cons("Requires") "template""<" TypeParam"," *">""type"Identifier->TypeParam cons("TemplateType") ExprDeclarativeSubClause*" ""return"Expr";"" "->Decl cons("DefDecl") "typename"Type->TypePar am prefer,cons("TypeParam") "class"Type->TypeParam prefer,cons("TypeParam") "class"TypeNameTypeParamList?->ClassClause cons("ClassClause") ClassClause->DeclDeclarativemoduleDeclarationsimportsLiteralsConceptsStatementsDataRepresenta{ } { } { tionexp} ortssortsStatDeclarativeExprDeclarativeDec{ } lDeclarativeSubClausecon{ text-freesyntaxSta} tDeclarati{ veSubClau} se*BlockStat->Decl cons("DefDecl"{ ) ExprDeclarativeSubClaus} e*"="Expr";"->Decl cons("DefDecl"){ TypeDeclarativeSub} { Clause*"="}DataRep->Decl cons("DefDec l"){ DeclDeclarativeSubClause*"} "Decl*" "->Decl cons("DefDecl"){ StatDeclarativeSubClause*";"->Decl} cons("NoDefDecl") ExprDeclarativeSubClause*";"->Decl{ } cons("NoDefDecl") TypeDeclarativeSubClause*";"->Decl cons("NoDefDecl") DeclDeclarativeSubClause*";"->Decl cons("NoDefDecl") sortsProcClauseProcNamecontext-freesyntax"procedure"ProcNameProcedureParamList->ProcClause{ cons("ProcClaus} e") ProcClause->StatDeclarativeIdentifier->ProcName"{ = "->ProcName} cons("Assign") sortsFunClauseFunNameconte{ xt-freesyntax"function"TypeFunNameFunctionParamList->FunClause} { } { } cons("FunClause") "define"TypeFunNameF{ unctionParamList->FunClause} cons("FunClause") "define"TypeFunName->FunCl{ } ause cons("FunClause") FunClause->ExprDeclarativeIdentifier->{ } FunNamesortsPredClausePredNamecontext-freesyntax"p{ } redicate"PredNameFunctionParamList->PredClause cons("PredClause") PredClause->ExprD{ eclarativeIdent}ifier->PredNamesortsTypeParamListTypeParamFunctionParamListFunctionParamProcedureParamListProcedureParamPar{ } amModecontext-freesyntax"(" TypeParam"," *")"->TypeParamList cons("Dummy"){ "(" FunctionParam","} *")"->FunctionParamList cons("Dummy"){ "(" ProcedureParam","} *")"->ProcedureParamList{ cons("Dummy") Type->TypeParam} cons("TypeExprParam") TypeIdentifier->TypeParam cons("TypeExprParam") "type"->TypeParam cons("AnonTypeParam") "type"Identifi{er->TypeParam cons("} TypeParam") "type"TypeParamList->TypeParam cons("AnonTypePParam") "type"IdentifierTypeParamList->TypeParam cons("TypePParam") TypeIden tifier->FunctionParam cons("Param"){ Type->FunctionParam} cons("AnonParam"){ ParamModeTypeIdentifier->Proc} { } edureParam prefer,cons("Param"){ } TypeIdentifier->ProcedureParam{ } cons("ObsParam"){ ParamModeTyp} e->ProcedureParam{ prefer,cons("AnonPa} ram") "type"Type->ProcedureParam{ cons("TypeOpParam")} "type"Type->{FunctionParam cons("TypeOpParam")} "obs"->ParamMode{ cons("Obs") "upd"->Param} Mode cons("Upd") "out"->ParamMode{ cons("Out") "exp"->ParamMode} cons("Exp") "giv"->ParamMod{ e cons("Giv") "del"->ParamM} ode cons("Del") "nrm"->ParamMode{ cons("Nrm")} sortsAttrClauseAttributecontext-freesyntax"["{ } Attribute"," *"]"->AttrClause{ cons("Attrs") AttrClause->SubClauseIdentifier->Attrib} { ute cons("Attr")} Identifier"(" Expr"," *")"->Att{ ribute cons("Attr}") sortsAlertClauseAlertNamecontext-freesyntax"guard"Expr->{ } AlertClause cons("G{ uard") "guard""} by"Expr->AlertCl{ause prefer,cons("Gua} rd") "alert"{ AlertName"i} f"Expr->AlertClause{ cons("AlertIf")} "alert"AlertName"unless"Expr{ } ->AlertCl{ ause cons("AlertUnless")} "success""if"Expr->AlertClause{ } cons("SuccessIf"){ } "success""unless"Expr->AlertClause cons("SuccessUnless"){ } "fail""if"Expr->AlertClause{ } cons("FailIf") "fail""unless"Expr->AlertCla{ use cons("FailUnle} ss") Identifier->AlertName{ } AlertCla{ use->SubCl}ausesortsForAllClausecontext-freesyntax"forall" TypeParam"," +->ForA{llClause cons("} ForAll") ForAllClause->SubClausesortsVarCla{ useVarN} amecontext-freesyntax"var"TypeVarName->VarClause{ cons("VarClause")} VarClause->ExprDeclarativeIdentif{ ier->VarNamesort sTypeNameTypeClauseClassClausecontext-freesyntax"type"TypeNameTypeParamList?->TypeClause} { } { cons("TypeClause")} Identifier->TypeNameTypeClause->TypeDeclarative"opens""("{ } Identifier"," {*")"->SubClause cons} ("Opens") "default""(" Identifier"," *")"->SubClause cons("Default") moduledesugarimports{ Magnoliamagn} olia/commonsignatures{ ortsPosAnnotatio} nconstructorsarea:Int*Int*Int*Int*Int*Int->Annotationarea-in-file:String*Pos->AnnotationClass:Name*List(Type)->Sigstrate{ } giesdesugar=magnolia-io(filenam e-option,norm-tree;fix-imports;downup(try(norm0);repeat(preserve-annotation(norm1));try(preserve-annotation(n{ } orm2));strip-anno,try(preserve-annotation(norm-forall+norm-cxx))))ov{ er} ride-tree-handler(s|format)=sfilename-option{ } { =ArgOption(}"-f"+"--filename",where(<set-config>("-f",<id>)),!"-ff|--filenam{ } efSetsourcefilenametof")norm0:SName([n])->nnorm0:SName(n@[ , | ])->QName(n)norm0:RName(n)->QName(n)norm0:TypeTuple(ts)->Type(Tuple(),ts)norm0:PType(n,ps)->Type(n,ps’)where<map(try( MatchExpr( t)->MatchType(t) ))>ps=>ps’norm0:Type(n)->Type(n,[])norm0:TypeExpr(t)->TypeExpr(Unresolved(t))norm1:Name(n)->Name(<opname>n)norm2:AName(n,as)->AName(n,<map( x->Unresolved(x) )>as)norm1:Dummy(d)->dnorm1:IfThen(c,e)->If(c,e,Nop())norm1:PrintLn(es)->Call(Name("println"),[es’’])where<map(!Apply(Name("string"),[<id>]))>es=>es’;<foldr(!Literal(String("")),mkappend)>es’=>es’’norm1:Print(es)->Call(Name("print"),[es’’])where<map(!Apply(Name("string"),[<id>]))>es=>es’;<foldr(!Literal(String("\ ") ),mkappend)>es’=>e\ s’’mkappend:(e,Literal(String("")))->emkappend:(e1,e2)->Apply(Name(" ++ "),[e1,Apply(Name(" ++ "),[Literal(String("")),e2])])where<not(Literal(String("")))>e2norm\ \ 1:BinOp(e1,op,e2)->Apply(Name(<concat-strings>[" ",op," "]),[e1,e2])norm1:In(e1,e2)->Apply(Name(" in "),[e1,e2])norm1:NotIn(e1,e2)->Apply(Name(" notin "),[e1,e2])norm1:PreOp(op,e)->Apply(Name(<concat-strings>[op," "]),[e])norm1:Dec(s)->Int(<string-to-int>s)norm1:Hex(s)->Int(<hex-string-to-int>s)norm1:Oct(s)- >Int(<oct-string-to-int>s)norm1:Bin(s)->Int(<bin-string-to-int>s)norm1:Literal(l)->Literal(l,Unresolved())norm1:Var(v)->Var(v,Unresolved(),Upd())norm1:Index(e,as)->Apply(Name(" [ ]"),[e|as])norm1:Assign()->Name(" = ")norm1:Return()->Return(None())norm2:Struct(t,fs)->Struct(Unresolved(t),fs)norm2:Union(t,f)->Struct(Unresolved(t),f)norm2:LiteralTrue()->Literal(Bool(True()),Unresolved())norm2:LiteralFalse()->Literal(Bool(False()),Unresolved())norm2:ObsParam(t,n)->Param(n,Unresolved(t),Ob s())norm2:AnonParam(t)->Param(Name(" "),Unresolved(t),Obs())norm2:TypeOpParam(t)->Param(Name(" "),Unresolved(t),Typ())norm2:AnonParam(m,t)->Param(Name(" "),Unresolved(t),m)norm2:Param(m,t,n)->Param(n,Unresolved(t),m)norm2:Param(t,n)->Param(n,Unresolved(t),Obs())norm2:TypeExprParam(t,n)->Unresolved(Match(n,t))norm2:TypeExprParam(t)->Unresolved(Match(Name(" "),t))norm2:AnonTypeParam()->Unresolved(Match(Name(" "),Type()))norm2:TypeParam(t)->Unresolved(Match(t,Type()))norm2:AnonTypePParam (ts)->Unresolved(Type(Match(Name(" "),TypeFun(as)),ts))where<map( x->Type() )>ts=>asnorm2:TypePParam(t,ts)->Unresolved(Type(Match(t,TypeFun(as)),ts))where<try(norm1);map( x->Type() )>ts=>asnorm2=Block(filter(not(Nop())))norm2:Requires(n,ts,hp)->Requires(Unresolved(n),ts’,hp)where<map(!Unresolved(<id>))>ts=>ts’norm2:Hide(r)->rnorm2:TypeProtect(t,Some(b))->TypeProtect(Unresolved(t),b)norm2:OpProtect(FunClause(t,n,ps),Some(b))->OpProtect(Unresolved(Fun(n,t,ps)),b)norm2:Where(t1,t2)->Wher e(Unresolved(t1),Unresolved(t2))norm2:Apply(n,e)->Apply(Unresolved(n),e)norm2:Call(n,e)->Call(Unresolved(n),e)norm2:Open(vs,e)->Open(vs’,e)where<map(!Var(<id>,Unresolved(),Obs()))>vs=>vs’\ \ \ \ norm2:Assign(n,e)->Assign(Unresolved(n),e)norm2:FieldAssign(v,n,e)->FieldAssign(Unresolved(v),n,e)norm2:IndexedAssign(v,as,e)->IndexedAssign(Unresolved(v),as,e)norm2:VarDefTI(t,n,e)->Def(n,Var(n,Unresolved(t),Upd()),e,[])norm2:VarDefI(n,e)->Def(n,Var(n,None(),Upd()),e,[])norm2:VarDefT(t,n)->Def(n,Var( n,Unresolved(t),Upd()),None(),[])norm2:ConceptDef(n,ps,Some(bs),bd)->Def(n,Concept(n,ps,bs),bd,[])norm2:ConceptDef(n,ps,None(),bd)->Def(n,Concept(n,ps,[]),bd,[])norm2:AxiomDef(n,ps,bd)->Def(n,Axiom(n,ps,[]),bd,[])norm-forall:def@Def( , , , )->Def(n,sig,bd,[ForAll(ts’)|at])where<collect(MatchType(id))>def=>ts@[ | ];<alltd( MatchType(x)->x )>def=>Def(n,sig,bd,at);<map( MatchType(x)->Unresolved(Match(x,Type())) )>ts=>ts’norm-cxx:TmplDecl(Template(ps,rs),Def(n,sig,bd,at))->Def(n,sig,bd,<c oncat;debug>[[ForAll(<conc>(tts’,ps’))],rs,at])where<collect(TemplateType(id,id))>ps=>tts;<alltd( TemplateType( ,t)->Unresolved(Match(t,Type())) )>ps=>ps’;<map( TemplateType(ts, )->ts );concat>tts=>tts’norm-cxx:Def(n,Class(dn,ps),None(),at)->Def(n,Type(dn,ps),None(),at)norm-cxx:Def(n,Class(dn,ps),bd,at)->Def(n,Type(dn,ps),\ StructRep(bd),a\t)where<is-list>bdnorm2:DefDec\l(dclause,subs,bd)->Def(n,sig,bd’,subs’)where(n,sig):=<norm-decl-clause>dclause;s\ ubs’:=<norm-sub-clauses>subs;<try(Nop() ;!None())>bd=>bd’norm2:NoDefDecl(dclause,subs)->Def(n,sig,None(),subs’)where(n,sig):=<norm-decl-clause>dclause;subs’:=<norm-sub-clauses>subsnorm-decl-clause:FunClause(t,n,ps)->(n,Fun(n,Unresolved(t)\ \ \ \ ,ps))norm-decl-clause:FunClause(t,n)->(n,Fun(n,Unresolved(t),[]))norm-decl-clause:PredClause(n,ps)->(n,Fun(n,Unresolved(Name("bool")),ps))norm-decl-clause:ProcClause(n,ps)->(n,Proc(n,ps))norm-decl-clause:VarClause(t,n)->(n,Var(n,Unresolved(t),Upd()))norm-decl-clause:TypeClause(n,Some(ps))->

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    216 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us