module StrategoAlloy
imports Stratego [ Term => StrategoTerm
                   Var => StrategoVar
                   Id => StrategoId
                   StrChar => StrategoStrChar ]

imports alloy/Main
exports
  context-free syntax
    "@A" Specification "A@" -> StrategoTerm  {cons("ToTerm"),prefer}
    "@@" Paragraph* "@@" -> StrategoTerm  {cons("ToTerm"),prefer}
    "@D" Decl "D@"  -> StrategoTerm  {cons("ToTerm"),prefer}
    "@E" (Expr|RHSExpr) "E@"  -> StrategoTerm  {cons("ToTerm"),prefer}
    "@N" Name "N@"  -> StrategoTerm  {cons("ToTerm"),prefer}
    "@S" Paragraph "S@" -> StrategoTerm  {cons("ToTerm"),prefer}
    "@L" LetDecl   "L@" -> StrategoTerm  {cons("ToTerm"),prefer}

    "\\~" Expr             -> Expr                     {cons("ATranspose"),prefer}
    "~"   StrategoTerm    -> Name                     {cons("FromTerm"),prefer}
    "~*"  StrategoTerm    -> {Name ","}+              {cons("FromTerm")}
    "~"   StrategoTerm    -> SigExt?                  {cons("FromTerm"),prefer}
    "~*"  StrategoTerm    -> SigQual+                 {cons("FromTerm"),prefer}
    "~*"  StrategoTerm    -> {Decl ","}+              {cons("FromTerm")}
    "~"   StrategoTerm    -> Block?                   {cons("FromTerm"),prefer}
    "~"   StrategoTerm    -> Expr                     {cons("FromTerm"),prefer}
    "~*"  StrategoTerm    -> {(Expr|RHSExpr) ","}*    {cons("FromTerm"),prefer}
    "~*"  StrategoTerm    -> (Ref ".")?               {cons("FromTerm"),prefer}
    "~*"  StrategoTerm    -> Args?                    {cons("FromTerm"),prefer}
    "~"   StrategoTerm    -> Block                    {cons("FromTerm"),prefer}
    "~*"  StrategoTerm    -> {LetDecl ","}+           {cons("FromTerm")}

  variables
  "private?"                -> Private?                 {prefer}
  "disjoint"[0-9]*"?"         -> Disj?                    {prefer}

  context-free start-symbols Module