Пример #1
0
 /// <summary>
 /// declaration
 ///     : declaration-specifiers init-declarator-list_opt ;
 ///     ;
 ///
 /// If the declaration is a typedef, add the name into the environment.
 /// </summary>
 /// <returns></returns>
 public static Parserc.Parser <T, Declaration> Declaration()
 {
     return(DeclarationSpecifiers()
            .Bind(specifiers => InitDeclaratorList()
                  .Bind(declarators => Match <T_PUNC_SEMICOLON>()
                        .Bind(_ => {
         var decl = new Declaration(specifiers, declarators);
         if (decl.IsTypedef)
         {
             foreach (var name in decl.DeclNames)
             {
                 Env.AddTypedefName(decl.Pos.line, name);
             }
         }
         return Result <T, Declaration>(decl);
     }))));
 }