Advertisement
tinyevil

Untitled

May 22nd, 2019
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. struct DataTypeDeclarationField :
  2.     g::And<id, colon, Expression, g::Opt<g::And<equal, Expression>>>
  3. {
  4.     Field make(DeclarationScopeParser& parser)
  5.     {
  6.         Box<ast::Expression> init;
  7.         if ( auto c = factor<3>().capture() )
  8.             init = c->factor<1>().make(parser);
  9.  
  10.         return {
  11.             ast::Symbol(factor<0>().token()),
  12.             flattenConstraints(factor<2>().make(parser)),
  13.             std::move(init)
  14.         };
  15.     }
  16. };
  17.  
  18.  
  19. Field parse_DataTypeDeclarationField(DeclarationScopeParser& parser) {
  20.     auto id = parse_id(parser);
  21.     parse_colon(parser);
  22.     auto expression = parse_Expression(parser);
  23.     ast::Expression rhs = nullptr;
  24.     if (try_parse_equal(parser)) {
  25.         rhs = parse_Expression(parser);
  26.     }
  27.     return {
  28.         ast::Symbol(id.token()),
  29.         flattenConstraints(expression),
  30.         std::move(rhs)
  31.     };
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement