module Stratego-C
imports C StrategoRenamed
hiddens
  context-free start-symbols StrategoModule

exports
  context-free syntax
                         "|[" TranslationUnit "]|" -> StrategoTerm {cons("ToTerm")}
      "translation-unit" "|[" TranslationUnit "]|" -> StrategoTerm {cons("ToTerm")}
    "c:translation-unit" "|[" TranslationUnit "]|" -> StrategoTerm {cons("ToTerm")}

    "ext-def*" "|["  ExternalDef+ "]|"-> StrategoTerm {cons("ToTerm")}

            "|["  CommaExp "]|" -> StrategoTerm {cons("ToTerm")}
      "exp" "|["  CommaExp "]|" -> StrategoTerm {cons("ToTerm")}
    "c:exp" "|["  CommaExp "]|" -> StrategoTerm {cons("ToTerm")}

            "|["  Stm "]|" -> StrategoTerm {cons("ToTerm")}
      "stm" "|["  Stm "]|" -> StrategoTerm {cons("ToTerm")}
    "c:stm" "|["  Stm "]|" -> StrategoTerm {cons("ToTerm")}

      "stm*" "|[" Stm* "]|" -> StrategoTerm {cons("ToTerm")}
    "c:stm*" "|[" Stm* "]|" -> StrategoTerm {cons("ToTerm")}

            "|["  Declaration "]|" -> StrategoTerm {cons("ToTerm")}
      "dec" "|["  Declaration "]|" -> StrategoTerm {cons("ToTerm")}
    "c:dec" "|["  Declaration "]|" -> StrategoTerm {cons("ToTerm")}

      "dec*" "|["  Declaration* "]|" -> StrategoTerm {cons("ToTerm")}
    "c:dec*" "|["  Declaration* "]|" -> StrategoTerm {cons("ToTerm")}

                "|["  FunDef "]|" -> StrategoTerm {cons("ToTerm")}
      "fun-def" "|["  FunDef "]|" -> StrategoTerm {cons("ToTerm")}
    "c:fun-def" "|["  FunDef "]|" -> StrategoTerm {cons("ToTerm")}

                "|["  IdDeclarator "]|" -> StrategoTerm {cons("ToTerm")}
      "id-decl" "|["  IdDeclarator "]|" -> StrategoTerm {cons("ToTerm")}
    "c:id-decl" "|["  IdDeclarator "]|" -> StrategoTerm {cons("ToTerm")}

                "|["  MemberDeclaration "]|" -> StrategoTerm {cons("ToTerm")}
      "mem-dec" "|["  MemberDeclaration "]|" -> StrategoTerm {cons("ToTerm")}
    "c:mem-dec" "|["  MemberDeclaration "]|" -> StrategoTerm {cons("ToTerm")}

                  "|["  ParamDeclaration "]|" -> StrategoTerm {cons("ToTerm")}
      "param-dec" "|["  ParamDeclaration "]|" -> StrategoTerm {cons("ToTerm")}
    "c:param-dec" "|["  ParamDeclaration "]|" -> StrategoTerm {cons("ToTerm")}

                  "|["  TypeSpecifier "]|" -> StrategoTerm {cons("ToTerm")}
      "type-spec" "|["  TypeSpecifier "]|" -> StrategoTerm {cons("ToTerm")}
    "c:type-spec" "|["  TypeSpecifier "]|" -> StrategoTerm {cons("ToTerm")}

                  "|["  TypeName "]|" -> StrategoTerm {cons("ToTerm")}
      "type-name" "|["  TypeName "]|" -> StrategoTerm {cons("ToTerm")}
    "c:type-name" "|["  TypeName "]|" -> StrategoTerm {cons("ToTerm")}

                "|[" VarDecl "]|" -> StrategoTerm {cons("ToTerm")}
      "var-dec" "|[" VarDecl "]|" -> StrategoTerm {cons("ToTerm")}
    "c:var-dec" "|[" VarDecl "]|" -> StrategoTerm {cons("ToTerm")}

    "~var-dec:" StrategoTerm -> VarDecl {cons("FromTerm")} 
    "~var-dec*:" StrategoTerm -> {VarDecl ","}* {cons("FromTerm")}

    "~id:"      StrategoTerm -> ID           {cons("FromTerm")}
    "~id-decl:" StrategoTerm -> IdDeclarator {cons("FromTerm")}

    "~dec:"   StrategoTerm -> Declaration  {cons("FromTerm")}
    "~dec*:"  StrategoTerm -> Declaration+ {cons("FromTerm")}

    "~stm:"  StrategoTerm -> Stm        {cons("FromTerm")}
    "~stm*:" StrategoTerm -> Stm*       {cons("FromTerm")}

    "~exp:"  StrategoTerm -> PrimaryExp {cons("FromTerm")}
    "~exp*:" StrategoTerm -> {AssignExp ","}+ {cons("FromTerm")}

    "~type-name:"  StrategoTerm -> TypeName                {cons("FromTerm")}

    "~type-spec:"  StrategoTerm -> TypeSpecifier           {cons("FromTerm")}
    "~param-dec*:" StrategoTerm -> {ParamDeclaration ","}+ {cons("FromTerm")}
    "~mem-dec*:"   StrategoTerm -> MemberDeclaration+      {cons("FromTerm")}

    "~ext-def*:"   StrategoTerm -> ExternalDef+ {cons("FromTerm")}

    "~init:" StrategoTerm -> Initializer {cons("FromTerm")}
    "~init*:" StrategoTerm -> {Initializer ","}+ {cons("FromTerm")} 

