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) {
3333 docs_step.dependOn(&docgen_cmd.step);
3434 docs_step.dependOn(&docgen_home_cmd.step);
3535
36 const test_step = b.step("test", "Run all the tests");
37
3638 if (findLLVM(b)) |llvm| {
3739 // find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library
3840 const build_info = b.exec([][]const u8{b.zig_exe, "BUILD_INFO"});
......@@ -72,15 +74,16 @@ pub fn build(b: &Builder) {
7274
7375 b.default_step.dependOn(&exe.step);
7476 b.default_step.dependOn(docs_step);
77 test_step.dependOn(&exe.step);
7578
7679 b.installArtifact(exe);
7780 installStdLib(b);
81
7882 }
7983
8084
8185 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");
8286 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
8588 test_step.dependOn(docs_step);
8689
src-self-hosted/main.zig+5
......@@ -626,3 +626,8 @@ fn findZigLibDir(allocator: &mem.Allocator) -> %[]u8 {
626626
627627 return error.FileNotFound;
628628}
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 {
204204 LineComment,
205205 Zero,
206206 IntegerLiteral,
207 IntegerLiteralWithRadix,
207208 NumberDot,
208209 FloatFraction,
209210 FloatExponentUnsigned,
......@@ -454,7 +455,7 @@ pub const Tokenizer = struct {
454455 },
455456 State.Zero => switch (c) {
456457 'b', 'o', 'x' => {
457 state = State.IntegerLiteral;
458 state = State.IntegerLiteralWithRadix;
458459 },
459460 else => {
460461 // reinterpret as a normal number
......@@ -469,6 +470,16 @@ pub const Tokenizer = struct {
469470 'p', 'P', 'e', 'E' => {
470471 state = State.FloatExponentUnsigned;
471472 },
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 },
472483 '0'...'9', 'a'...'f', 'A'...'F' => {},
473484 else => break,
474485 },
......@@ -485,7 +496,7 @@ pub const Tokenizer = struct {
485496 },
486497 },
487498 State.FloatFraction => switch (c) {
488 'p', 'P', 'e', 'E' => {
499 'p', 'P' => {
489500 state = State.FloatExponentUnsigned;
490501 },
491502 '0'...'9', 'a'...'f', 'A'...'F' => {},