Changeset 89


Ignore:
Timestamp:
Sep 8, 2008 12:49:46 AM (16 years ago)
Author:
Anya Helene Bagge
Message:

concept syntax

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/eval/proc.str

    r73 r89  
    6666
    6767  eval-stat' =
     68        ?Assert(c)
     69  ;     if <eval-expr> c => Int(0) then
     70                complain(|"assert-failed")
     71        else
     72                id
     73        end
     74
     75  eval-stat' =
    6876        ?If(c,t,e)
    6977  ;     if <eval-expr> c => Int(0) then
     
    210218        -> fatal(LineMsg(["Call failed: "], [1]), 1)
    211219
     220  get-message: "assert-failed"
     221        -> fatal(LineMsg(["Assert failed: "], [1]), 1)
     222
    212223  get-message: "bind-primitive-args-failed"
    213224        -> interr(LineMsg(["Failed to bind primitive procedure argument list.  Maybe there's something wrong with your primitive.mgm."], [1]), 1)
  • trunk/src/lib/libmagnolia/pp.str

    r87 r89  
    7878
    7979  pp-stat: Assign(v,e) -> H([v, S(" = "), e, S(";")])
     80  pp-stat: Assert(c) -> H([S("assert"), c, S(";")])
    8081  pp-stat: DotAssign(v,n,e) -> H([v, S("."), n, S(" = "), e, S(";")])
    8182  pp-stat: Call(s,es) -> H([KW(S("call")), S(" "), PROC(n), P(HC(es)), S(";")])
  • trunk/src/proc/mutify.str

    r88 r89  
    9595  ;     !Var(Name(v),t,Upd()) => a
    9696
     97  mut:  stmt@Assert(c@Apply(Fun(_,t,_),_){ca*}){aa*}
     98        -> Seq([Def(Name(v), a, None()){ca*}, Assign(a, c){ca*},
     99                 Assert(a){aa*}]){aa*}
     100  where new => v
     101  ;     !Var(Name(v),t,Upd()) => a
     102
    97103  mut:  stmt@Call(p,as){ca*} -> Seq(<concat> [ss, [Call(p,as'){ca*}]]){ca*}
    98104  where <repeat(mut-temp <+ mut-temp')> (as, [], []) => ([], as', ss@[_|_])
  • trunk/src/sem/resolve.str

    r88 r89  
    284284  ;     {| symbol: <stat-resolve> e => e' |}
    285285
     286  stat-resolve-simple: Assert(c) -> Assert(c')
     287  where <expr-resolve> c => c'
     288
    286289  stat-resolve-simple: Comment(c) -> Comment(c)
    287290
  • trunk/src/sig/magnolia-tree.rtg

    r88 r89  
    77    StatList            -> <cons>(Stat, StatList)   | <nil>()
    88    SymList             -> <cons>(Sym, SymList)   | <nil>()
     9    TypeList            -> <cons>(Type, TypeList)   | <nil>()
    910    ModuleClauseList    -> <cons>(ModuleClause, ModuleClauseList) | <nil>()
    1011    IdentifierList      -> <cons>(Identifier, IdentifierList) | <nil>()
     
    1920    Sig                 -> Var(Name, Type, Mode)
    2021    Sig                 -> Class(Name)
     22    Sig                 -> Concept(Name, TypeList, TypeList)
     23    Sig                 -> Axiom(Name, ParamList, IdentifierList)
    2124    Sig                 -> Unresolved(Name)
    2225    Sig                 -> None()
     
    3437    Stat                -> Sym
    3538    Stat                -> Assign(Sig,Expr)
     39    Stat                -> Assert(Expr)
    3640    Stat                -> DotAssign(Sig,Name,Expr)
    3741    Stat                -> Call(Sig,ExprList)
  • trunk/src/syn/Concepts.sdf

    r79 r89  
    2323    Decl
    2424    Identifier
     25    ConceptParameter
     26    BaseConcepts
     27    ConceptExpr
     28    RenameSpec
     29    Renaming
    2530
    2631  context-free syntax
    2732
    28     "concept" Identifier "{" Decl "}" -> Decl {cons("ConceptDef")}
     33    "concept" Identifier "<" {ConceptParameter ","}* ">" BaseConcepts? "{" Decl* "}" -> Decl {cons("ConceptDef")}
     34
     35    "typename" Identifier -> ConceptParameter {cons("Class")}
    2936
    3037    "axiom" Identifier "(" {FunctionParameter ","}* ")" Stat
     
    3239
    3340    "assert" Expr ";" -> Stat {cons("Assert")}
     41
     42    ":" {ConceptExpr ","}* -> BaseConcepts {cons("Dummy")}
     43
     44    Identifier "<" {Identifier ","}* ">" RenameSpec? -> ConceptExpr {cons("ConceptExpr")}
     45
     46    "rename" Renaming -> RenameSpec {cons("Rename")}
     47
     48    "function" Type Identifier "(" {FunctionParameter ","}* ")" "{" "return" Expr ";" "}" -> Renaming {cons("Renaming")}
     49
     50    "function" Type Identifier "(" {FunctionParameter ","}* ")" "=" Expr ";" -> Renaming {cons("Renaming")}
     51
     52    "{" Renaming* "}" -> Renaming {cons("RenameBlock")}
     53
  • trunk/src/syn/Magnolia.sdf

    r79 r89  
    3838  context-free syntax
    3939
    40     ModuleHead "{" Decl+ "}" -> Program {cons("MagnoliaTree")}
     40    ModuleHead "{" Decl* "}" -> Program {cons("MagnoliaTree")}
    4141
    4242    -> ModuleHead {cons("SimpleModule")}
  • trunk/src/syn/desugar.str

    r87 r89  
    4242  norm0: SName(n@[_,_|_]) -> QName(<map(\x -> Name(x)\ )>n)
    4343  norm0: RName(n) -> QName(<map(\x -> Name(x)\ )>n)
     44
     45  norm1: Dummy(d) -> d
    4446
    4547  norm1: IfThen(c,e) -> If(c, e, Nop())
     
    9092  norm2: CtorDef(n,ps,None(),bd) -> Def(n, Proc(n,ps), bd)
    9193
     94  norm2: ConceptDef(n,ps,Some(bs),bd) -> Def(n,Concept(n,ps,bs), bd)
     95  norm2: ConceptDef(n,ps,None(),bd) -> Def(n,Concept(n,ps,[]), bd)
     96
     97  norm2: AxiomDef(n, ps, bd) -> Def(n, Axiom(n, ps, []), bd)
    9298  norm-tree: MagnoliaTree(SimpleModule(), m)
    9399        -> MagnoliaTree(VerInfo(0,0,<version-string>""),
Note: See TracChangeset for help on using the changeset viewer.