diff --git a/doc/docgen.zig b/doc/docgen.zig index f2d2e2845b8e..8d920dcf6a56 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -887,16 +887,6 @@ fn tokenizeAndPrintRaw( next_tok_is_fn = true; }, - .keyword_undefined, - .keyword_null, - .keyword_true, - .keyword_false, - => { - try out.writeAll(""); - try writeEscaped(out, src[token.loc.start..token.loc.end]); - try out.writeAll(""); - }, - .string_literal, .multiline_string_literal_line, .char_literal, @@ -921,9 +911,18 @@ fn tokenizeAndPrintRaw( }, .identifier => { - if (prev_tok_was_fn) { + const tok_bytes = src[token.loc.start..token.loc.end]; + if (mem.eql(u8, tok_bytes, "undefined") or + mem.eql(u8, tok_bytes, "null") or + mem.eql(u8, tok_bytes, "true") or + mem.eql(u8, tok_bytes, "false")) + { + try out.writeAll(""); + try writeEscaped(out, tok_bytes); + try out.writeAll(""); + } else if (prev_tok_was_fn) { try out.writeAll(""); - try writeEscaped(out, src[token.loc.start..token.loc.end]); + try writeEscaped(out, tok_bytes); try out.writeAll(""); } else { const is_int = blk: { @@ -938,12 +937,12 @@ fn tokenizeAndPrintRaw( } break :blk true; }; - if (is_int or isType(src[token.loc.start..token.loc.end])) { + if (is_int or isType(tok_bytes)) { try out.writeAll(""); - try writeEscaped(out, src[token.loc.start..token.loc.end]); + try writeEscaped(out, tok_bytes); try out.writeAll(""); } else { - try writeEscaped(out, src[token.loc.start..token.loc.end]); + try writeEscaped(out, tok_bytes); } } }, diff --git a/doc/langref.html.in b/doc/langref.html.in index 336db082f160..62e3da727785 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -11564,11 +11564,7 @@ PrimaryTypeExpr / INTEGER / KEYWORD_comptime TypeExpr / KEYWORD_error DOT IDENTIFIER - / KEYWORD_false - / KEYWORD_null / KEYWORD_anyframe - / KEYWORD_true - / KEYWORD_undefined / KEYWORD_unreachable / STRINGLITERAL / SwitchExpr @@ -11937,7 +11933,6 @@ KEYWORD_errdefer <- 'errdefer' end_of_word KEYWORD_error <- 'error' end_of_word KEYWORD_export <- 'export' end_of_word KEYWORD_extern <- 'extern' end_of_word -KEYWORD_false <- 'false' end_of_word KEYWORD_fn <- 'fn' end_of_word KEYWORD_for <- 'for' end_of_word KEYWORD_if <- 'if' end_of_word @@ -11945,7 +11940,6 @@ KEYWORD_inline <- 'inline' end_of_word KEYWORD_noalias <- 'noalias' end_of_word KEYWORD_nosuspend <- 'nosuspend' end_of_word KEYWORD_noinline <- 'noinline' end_of_word -KEYWORD_null <- 'null' end_of_word KEYWORD_opaque <- 'opaque' end_of_word KEYWORD_or <- 'or' end_of_word KEYWORD_orelse <- 'orelse' end_of_word @@ -11959,9 +11953,7 @@ KEYWORD_suspend <- 'suspend' end_of_word KEYWORD_switch <- 'switch' end_of_word KEYWORD_test <- 'test' end_of_word KEYWORD_threadlocal <- 'threadlocal' end_of_word -KEYWORD_true <- 'true' end_of_word KEYWORD_try <- 'try' end_of_word -KEYWORD_undefined <- 'undefined' end_of_word KEYWORD_union <- 'union' end_of_word KEYWORD_unreachable <- 'unreachable' end_of_word KEYWORD_usingnamespace <- 'usingnamespace' end_of_word @@ -11974,13 +11966,13 @@ keyword <- KEYWORD_align / KEYWORD_allowzero / KEYWORD_and / KEYWORD_anyframe / KEYWORD_break / KEYWORD_callconv / KEYWORD_catch / KEYWORD_comptime / KEYWORD_const / KEYWORD_continue / KEYWORD_defer / KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer / KEYWORD_error / KEYWORD_export - / KEYWORD_extern / KEYWORD_false / KEYWORD_fn / KEYWORD_for / KEYWORD_if + / KEYWORD_extern / KEYWORD_fn / KEYWORD_for / KEYWORD_if / KEYWORD_inline / KEYWORD_noalias / KEYWORD_nosuspend / KEYWORD_noinline - / KEYWORD_null / KEYWORD_opaque / KEYWORD_or / KEYWORD_orelse / KEYWORD_packed + / KEYWORD_opaque / KEYWORD_or / KEYWORD_orelse / KEYWORD_packed / KEYWORD_pub / KEYWORD_resume / KEYWORD_return / KEYWORD_linksection / KEYWORD_struct / KEYWORD_suspend / KEYWORD_switch - / KEYWORD_test / KEYWORD_threadlocal / KEYWORD_true / KEYWORD_try - / KEYWORD_undefined / KEYWORD_union / KEYWORD_unreachable + / KEYWORD_test / KEYWORD_threadlocal / KEYWORD_try + / KEYWORD_union / KEYWORD_unreachable / KEYWORD_usingnamespace / KEYWORD_var / KEYWORD_volatile / KEYWORD_while {#header_close#} diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig index ee2b0982a9fe..535dc994839e 100644 --- a/lib/std/zig/ast.zig +++ b/lib/std/zig/ast.zig @@ -346,10 +346,6 @@ pub const Tree = struct { .char_literal, .integer_literal, .float_literal, - .false_literal, - .true_literal, - .null_literal, - .undefined_literal, .unreachable_literal, .string_literal, .multiline_string_literal, @@ -711,10 +707,6 @@ pub const Tree = struct { .char_literal, .integer_literal, .float_literal, - .false_literal, - .true_literal, - .null_literal, - .undefined_literal, .unreachable_literal, .identifier, .deref, @@ -2757,14 +2749,6 @@ pub const Node = struct { /// Both lhs and rhs unused. float_literal, /// Both lhs and rhs unused. - false_literal, - /// Both lhs and rhs unused. - true_literal, - /// Both lhs and rhs unused. - null_literal, - /// Both lhs and rhs unused. - undefined_literal, - /// Both lhs and rhs unused. unreachable_literal, /// Both lhs and rhs unused. /// Most identifiers will not have explicit AST nodes, however for expressions diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index 922b1e9858c0..5904e1816f14 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -2226,11 +2226,7 @@ const Parser = struct { /// / INTEGER /// / KEYWORD_comptime TypeExpr /// / KEYWORD_error DOT IDENTIFIER - /// / KEYWORD_false - /// / KEYWORD_null /// / KEYWORD_anyframe - /// / KEYWORD_true - /// / KEYWORD_undefined /// / KEYWORD_unreachable /// / STRINGLITERAL /// / SwitchExpr @@ -2273,38 +2269,6 @@ const Parser = struct { .rhs = undefined, }, }), - .keyword_false => return p.addNode(.{ - .tag = .false_literal, - .main_token = p.nextToken(), - .data = .{ - .lhs = undefined, - .rhs = undefined, - }, - }), - .keyword_true => return p.addNode(.{ - .tag = .true_literal, - .main_token = p.nextToken(), - .data = .{ - .lhs = undefined, - .rhs = undefined, - }, - }), - .keyword_null => return p.addNode(.{ - .tag = .null_literal, - .main_token = p.nextToken(), - .data = .{ - .lhs = undefined, - .rhs = undefined, - }, - }), - .keyword_undefined => return p.addNode(.{ - .tag = .undefined_literal, - .main_token = p.nextToken(), - .data = .{ - .lhs = undefined, - .rhs = undefined, - }, - }), .keyword_unreachable => return p.addNode(.{ .tag = .unreachable_literal, .main_token = p.nextToken(), diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig index 20ec7d3bfa68..71b071d6fb50 100644 --- a/lib/std/zig/render.zig +++ b/lib/std/zig/render.zig @@ -187,11 +187,7 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I .integer_literal, .float_literal, .char_literal, - .true_literal, - .false_literal, - .null_literal, .unreachable_literal, - .undefined_literal, .anyframe_literal, .string_literal, => return renderToken(ais, tree, main_tokens[node], space), diff --git a/lib/std/zig/tokenizer.zig b/lib/std/zig/tokenizer.zig index 1db2967c52f8..3fdbb3ec7b03 100644 --- a/lib/std/zig/tokenizer.zig +++ b/lib/std/zig/tokenizer.zig @@ -32,7 +32,6 @@ pub const Token = struct { .{ "error", .keyword_error }, .{ "export", .keyword_export }, .{ "extern", .keyword_extern }, - .{ "false", .keyword_false }, .{ "fn", .keyword_fn }, .{ "for", .keyword_for }, .{ "if", .keyword_if }, @@ -40,7 +39,6 @@ pub const Token = struct { .{ "noalias", .keyword_noalias }, .{ "noinline", .keyword_noinline }, .{ "nosuspend", .keyword_nosuspend }, - .{ "null", .keyword_null }, .{ "opaque", .keyword_opaque }, .{ "or", .keyword_or }, .{ "orelse", .keyword_orelse }, @@ -54,9 +52,7 @@ pub const Token = struct { .{ "switch", .keyword_switch }, .{ "test", .keyword_test }, .{ "threadlocal", .keyword_threadlocal }, - .{ "true", .keyword_true }, .{ "try", .keyword_try }, - .{ "undefined", .keyword_undefined }, .{ "union", .keyword_union }, .{ "unreachable", .keyword_unreachable }, .{ "usingnamespace", .keyword_usingnamespace }, @@ -157,7 +153,6 @@ pub const Token = struct { keyword_error, keyword_export, keyword_extern, - keyword_false, keyword_fn, keyword_for, keyword_if, @@ -165,7 +160,6 @@ pub const Token = struct { keyword_noalias, keyword_noinline, keyword_nosuspend, - keyword_null, keyword_opaque, keyword_or, keyword_orelse, @@ -179,9 +173,7 @@ pub const Token = struct { keyword_switch, keyword_test, keyword_threadlocal, - keyword_true, keyword_try, - keyword_undefined, keyword_union, keyword_unreachable, keyword_usingnamespace, @@ -280,7 +272,6 @@ pub const Token = struct { .keyword_error => "error", .keyword_export => "export", .keyword_extern => "extern", - .keyword_false => "false", .keyword_fn => "fn", .keyword_for => "for", .keyword_if => "if", @@ -288,7 +279,6 @@ pub const Token = struct { .keyword_noalias => "noalias", .keyword_noinline => "noinline", .keyword_nosuspend => "nosuspend", - .keyword_null => "null", .keyword_opaque => "opaque", .keyword_or => "or", .keyword_orelse => "orelse", @@ -302,9 +292,7 @@ pub const Token = struct { .keyword_switch => "switch", .keyword_test => "test", .keyword_threadlocal => "threadlocal", - .keyword_true => "true", .keyword_try => "try", - .keyword_undefined => "undefined", .keyword_union => "union", .keyword_unreachable => "unreachable", .keyword_usingnamespace => "usingnamespace", diff --git a/src/AstGen.zig b/src/AstGen.zig index a425540a386a..0a34e9a0cafd 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -370,10 +370,6 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: ast.Node.Index) InnerError!Zir.Ins .bool_not, .address_of, .float_literal, - .undefined_literal, - .true_literal, - .false_literal, - .null_literal, .optional_type, .block, .block_semicolon, @@ -759,10 +755,6 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr const result = try expr(gz, scope, .ref, node_datas[node].lhs); return rvalue(gz, rl, result, node); }, - .undefined_literal => return rvalue(gz, rl, .undef, node), - .true_literal => return rvalue(gz, rl, .bool_true, node), - .false_literal => return rvalue(gz, rl, .bool_false, node), - .null_literal => return rvalue(gz, rl, .null_value, node), .optional_type => { const operand = try typeExpr(gz, scope, node_datas[node].lhs); const result = try gz.addUnNode(.optional_type, operand, node); @@ -7852,10 +7844,6 @@ fn nodeMayNeedMemoryLocation(tree: *const ast.Tree, start_node: ast.Node.Index) .string_literal, .multiline_string_literal, .char_literal, - .true_literal, - .false_literal, - .null_literal, - .undefined_literal, .unreachable_literal, .identifier, .error_set_decl, @@ -8092,10 +8080,6 @@ fn nodeMayEvalToError(tree: *const ast.Tree, start_node: ast.Node.Index) enum { .string_literal, .multiline_string_literal, .char_literal, - .true_literal, - .false_literal, - .null_literal, - .undefined_literal, .unreachable_literal, .error_set_decl, .container_decl, @@ -8265,10 +8249,6 @@ fn nodeImpliesRuntimeBits(tree: *const ast.Tree, start_node: ast.Node.Index) boo .string_literal, .multiline_string_literal, .char_literal, - .true_literal, - .false_literal, - .null_literal, - .undefined_literal, .unreachable_literal, .identifier, .error_set_decl, diff --git a/src/translate_c/ast.zig b/src/translate_c/ast.zig index e1da1c7d0512..105893619107 100644 --- a/src/translate_c/ast.zig +++ b/src/translate_c/ast.zig @@ -928,23 +928,23 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { return renderCall(c, lhs, payload.args); }, .null_literal => return c.addNode(.{ - .tag = .null_literal, - .main_token = try c.addToken(.keyword_null, "null"), + .tag = .identifier, + .main_token = try c.addToken(.identifier, "null"), .data = undefined, }), .undefined_literal => return c.addNode(.{ - .tag = .undefined_literal, - .main_token = try c.addToken(.keyword_undefined, "undefined"), + .tag = .identifier, + .main_token = try c.addToken(.identifier, "undefined"), .data = undefined, }), .true_literal => return c.addNode(.{ - .tag = .true_literal, - .main_token = try c.addToken(.keyword_true, "true"), + .tag = .identifier, + .main_token = try c.addToken(.identifier, "true"), .data = undefined, }), .false_literal => return c.addNode(.{ - .tag = .false_literal, - .main_token = try c.addToken(.keyword_false, "false"), + .tag = .identifier, + .main_token = try c.addToken(.identifier, "false"), .data = undefined, }), .zero_literal => return c.addNode(.{ @@ -1599,8 +1599,8 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { const while_tok = try c.addToken(.keyword_while, "while"); _ = try c.addToken(.l_paren, "("); const cond = try c.addNode(.{ - .tag = .true_literal, - .main_token = try c.addToken(.keyword_true, "true"), + .tag = .identifier, + .main_token = try c.addToken(.identifier, "true"), .data = undefined, }); _ = try c.addToken(.r_paren, ")");