authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-01-03 18:25:17-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-01-03 18:25:17-05:00
loga45db7e853c2aa04ff7a91dbda975f181aa467bd
tree2f89718ec3edb9a2fec29753d60ffcd630af8698
parent5b156031e92c66c1bea71d5eb6c337b23185d65d

add building the self hosted compiler to the main test suite


3 files changed, 22 insertions(+), 3 deletions(-)

build.zig+4-1
...@@ -33,6 +33,8 @@ pub fn build(b: &Builder) {...@@ -33,6 +33,8 @@ pub fn build(b: &Builder) {
33 docs_step.dependOn(&docgen_cmd.step);33 docs_step.dependOn(&docgen_cmd.step);
34 docs_step.dependOn(&docgen_home_cmd.step);34 docs_step.dependOn(&docgen_home_cmd.step);
3535
36 const test_step = b.step("test", "Run all the tests");
37
36 if (findLLVM(b)) |llvm| {38 if (findLLVM(b)) |llvm| {
37 // find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library39 // find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library
38 const build_info = b.exec([][]const u8{b.zig_exe, "BUILD_INFO"});40 const build_info = b.exec([][]const u8{b.zig_exe, "BUILD_INFO"});
...@@ -72,15 +74,16 @@ pub fn build(b: &Builder) {...@@ -72,15 +74,16 @@ pub fn build(b: &Builder) {
7274
73 b.default_step.dependOn(&exe.step);75 b.default_step.dependOn(&exe.step);
74 b.default_step.dependOn(docs_step);76 b.default_step.dependOn(docs_step);
77 test_step.dependOn(&exe.step);
7578
76 b.installArtifact(exe);79 b.installArtifact(exe);
77 installStdLib(b);80 installStdLib(b);
81
78 }82 }
7983
8084
81 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");85 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");
82 const with_lldb = b.option(bool, "with-lldb", "Run tests in LLDB to get a backtrace if one fails") ?? false;86 const with_lldb = b.option(bool, "with-lldb", "Run tests in LLDB to get a backtrace if one fails") ?? false;
83 const test_step = b.step("test", "Run all the tests");
8487
85 test_step.dependOn(docs_step);88 test_step.dependOn(docs_step);
8689
src-self-hosted/main.zig+5
...@@ -626,3 +626,8 @@ fn findZigLibDir(allocator: &mem.Allocator) -> %[]u8 {...@@ -626,3 +626,8 @@ fn findZigLibDir(allocator: &mem.Allocator) -> %[]u8 {
626626
627 return error.FileNotFound;627 return error.FileNotFound;
628}628}
629
630test "import tests" {
631 _ = @import("tokenizer.zig");
632 _ = @import("parser.zig");
633}
src-self-hosted/tokenizer.zig+13-2
...@@ -204,6 +204,7 @@ pub const Tokenizer = struct {...@@ -204,6 +204,7 @@ pub const Tokenizer = struct {
204 LineComment,204 LineComment,
205 Zero,205 Zero,
206 IntegerLiteral,206 IntegerLiteral,
207 IntegerLiteralWithRadix,
207 NumberDot,208 NumberDot,
208 FloatFraction,209 FloatFraction,
209 FloatExponentUnsigned,210 FloatExponentUnsigned,
...@@ -454,7 +455,7 @@ pub const Tokenizer = struct {...@@ -454,7 +455,7 @@ pub const Tokenizer = struct {
454 },455 },
455 State.Zero => switch (c) {456 State.Zero => switch (c) {
456 'b', 'o', 'x' => {457 'b', 'o', 'x' => {
457 state = State.IntegerLiteral;458 state = State.IntegerLiteralWithRadix;
458 },459 },
459 else => {460 else => {
460 // reinterpret as a normal number461 // reinterpret as a normal number
...@@ -469,6 +470,16 @@ pub const Tokenizer = struct {...@@ -469,6 +470,16 @@ pub const Tokenizer = struct {
469 'p', 'P', 'e', 'E' => {470 'p', 'P', 'e', 'E' => {
470 state = State.FloatExponentUnsigned;471 state = State.FloatExponentUnsigned;
471 },472 },
473 '0'...'9' => {},
474 else => break,
475 },
476 State.IntegerLiteralWithRadix => switch (c) {
477 '.' => {
478 state = State.NumberDot;
479 },
480 'p', 'P' => {
481 state = State.FloatExponentUnsigned;
482 },
472 '0'...'9', 'a'...'f', 'A'...'F' => {},483 '0'...'9', 'a'...'f', 'A'...'F' => {},
473 else => break,484 else => break,
474 },485 },
...@@ -485,7 +496,7 @@ pub const Tokenizer = struct {...@@ -485,7 +496,7 @@ pub const Tokenizer = struct {
485 },496 },
486 },497 },
487 State.FloatFraction => switch (c) {498 State.FloatFraction => switch (c) {
488 'p', 'P', 'e', 'E' => {499 'p', 'P' => {
489 state = State.FloatExponentUnsigned;500 state = State.FloatExponentUnsigned;
490 },501 },
491 '0'...'9', 'a'...'f', 'A'...'F' => {},502 '0'...'9', 'a'...'f', 'A'...'F' => {},