diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-11-21 09:41:49 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-21 09:41:49 -0800 |
| commit | 7dcda5b0e8b2a6e001c4fa29d748cd093ca57436 (patch) | |
| tree | 75fdb247bdad82586755f01d647d0dc952c16cc4 /src/stage1/parser.cpp | |
| parent | bf0cc32aa64002299361a30c5e4b701e99da5dea (diff) | |
| parent | ccdaf946b969661220737ec747e5a720b13d0bc7 (diff) | |
| download | zig-7dcda5b0e8b2a6e001c4fa29d748cd093ca57436.tar.gz zig-7dcda5b0e8b2a6e001c4fa29d748cd093ca57436.zip | |
Merge pull request #7182 from LemonBoy/externnnn
Initial implementation of @extern builtin
Diffstat (limited to 'src/stage1/parser.cpp')
| -rw-r--r-- | src/stage1/parser.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/stage1/parser.cpp b/src/stage1/parser.cpp index a49773e9ca..eab4ea0f77 100644 --- a/src/stage1/parser.cpp +++ b/src/stage1/parser.cpp @@ -1652,18 +1652,21 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) { // TODO: This is not in line with the grammar. // Because the prev stage 1 tokenizer does not parse // @[a-zA-Z_][a-zA-Z0-9_] as one token, it has to do a - // hack, where it accepts '@' (IDENTIFIER / KEYWORD_export). + // hack, where it accepts '@' (IDENTIFIER / KEYWORD_export / + // KEYWORD_extern). // I'd say that it's better if '@' is part of the builtin // identifier token. Token *at_sign = eat_token_if(pc, TokenIdAtSign); if (at_sign != nullptr) { Buf *name; - Token *token = eat_token_if(pc, TokenIdKeywordExport); - if (token == nullptr) { + Token *token; + if ((token = eat_token_if(pc, TokenIdKeywordExport)) != nullptr) { + name = buf_create_from_str("export"); + } else if ((token = eat_token_if(pc, TokenIdKeywordExtern)) != nullptr) { + name = buf_create_from_str("extern"); + } else { token = expect_token(pc, TokenIdSymbol); name = token_buf(token); - } else { - name = buf_create_from_str("export"); } AstNode *res = ast_expect(pc, ast_parse_fn_call_arguments); |
