Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct DataTypeDeclarationField :
- g::And<id, colon, Expression, g::Opt<g::And<equal, Expression>>>
- {
- Field make(DeclarationScopeParser& parser)
- {
- Box<ast::Expression> init;
- if ( auto c = factor<3>().capture() )
- init = c->factor<1>().make(parser);
- return {
- ast::Symbol(factor<0>().token()),
- flattenConstraints(factor<2>().make(parser)),
- std::move(init)
- };
- }
- };
- Field parse_DataTypeDeclarationField(DeclarationScopeParser& parser) {
- auto id = parse_id(parser);
- parse_colon(parser);
- auto expression = parse_Expression(parser);
- ast::Expression rhs = nullptr;
- if (try_parse_equal(parser)) {
- rhs = parse_Expression(parser);
- }
- return {
- ast::Symbol(id.token()),
- flattenConstraints(expression),
- std::move(rhs)
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement