authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-06 16:15:12-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-11 13:11:58-05:00
logde30438ed2efb909538f3177cced441b57eb1a5d
treea15777174a890655b0fc20076e86547b8de4cf09
parentae0a219d1f5495acc4d82421fa24d84186c2a40d
signaturelock-open Commit is signed but in an unrecognized format.

stage1 parser code for anon container lit


1 files changed, 16 insertions(+), 10 deletions(-)

src/parser.cpp+16-10
...@@ -81,7 +81,7 @@ static AstNode *ast_parse_for_type_expr(ParseContext *pc);...@@ -81,7 +81,7 @@ static AstNode *ast_parse_for_type_expr(ParseContext *pc);
81static AstNode *ast_parse_while_type_expr(ParseContext *pc);81static AstNode *ast_parse_while_type_expr(ParseContext *pc);
82static AstNode *ast_parse_switch_expr(ParseContext *pc);82static AstNode *ast_parse_switch_expr(ParseContext *pc);
83static AstNode *ast_parse_asm_expr(ParseContext *pc);83static AstNode *ast_parse_asm_expr(ParseContext *pc);
84static AstNode *ast_parse_enum_lit(ParseContext *pc);84static AstNode *ast_parse_anon_lit(ParseContext *pc);
85static AstNode *ast_parse_asm_output(ParseContext *pc);85static AstNode *ast_parse_asm_output(ParseContext *pc);
86static AsmOutput *ast_parse_asm_output_item(ParseContext *pc);86static AsmOutput *ast_parse_asm_output_item(ParseContext *pc);
87static AstNode *ast_parse_asm_input(ParseContext *pc);87static AstNode *ast_parse_asm_input(ParseContext *pc);
...@@ -1600,9 +1600,9 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {...@@ -1600,9 +1600,9 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {
1600 if (container_decl != nullptr)1600 if (container_decl != nullptr)
1601 return container_decl;1601 return container_decl;
16021602
1603 AstNode *enum_lit = ast_parse_enum_lit(pc);1603 AstNode *anon_lit = ast_parse_anon_lit(pc);
1604 if (enum_lit != nullptr)1604 if (anon_lit != nullptr)
1605 return enum_lit;1605 return anon_lit;
16061606
1607 AstNode *error_set_decl = ast_parse_error_set_decl(pc);1607 AstNode *error_set_decl = ast_parse_error_set_decl(pc);
1608 if (error_set_decl != nullptr)1608 if (error_set_decl != nullptr)
...@@ -1876,16 +1876,22 @@ static AstNode *ast_parse_asm_expr(ParseContext *pc) {...@@ -1876,16 +1876,22 @@ static AstNode *ast_parse_asm_expr(ParseContext *pc) {
1876 return res;1876 return res;
1877}1877}
18781878
1879static AstNode *ast_parse_enum_lit(ParseContext *pc) {1879static AstNode *ast_parse_anon_lit(ParseContext *pc) {
1880 Token *period = eat_token_if(pc, TokenIdDot);1880 Token *period = eat_token_if(pc, TokenIdDot);
1881 if (period == nullptr)1881 if (period == nullptr)
1882 return nullptr;1882 return nullptr;
18831883
1884 Token *identifier = expect_token(pc, TokenIdSymbol);1884 // anon enum literal
1885 AstNode *res = ast_create_node(pc, NodeTypeEnumLiteral, period);1885 Token *identifier = eat_token_if(pc, TokenIdSymbol);
1886 res->data.enum_literal.period = period;1886 if (identifier != nullptr) {
1887 res->data.enum_literal.identifier = identifier;1887 AstNode *res = ast_create_node(pc, NodeTypeEnumLiteral, period);
1888 return res;1888 res->data.enum_literal.period = period;
1889 res->data.enum_literal.identifier = identifier;
1890 return res;
1891 }
1892
1893 // anon container literal
1894 return ast_parse_init_list(pc);
1889}1895}
18901896
1891// AsmOutput <- COLON AsmOutputList AsmInput?1897// AsmOutput <- COLON AsmOutputList AsmInput?