Skip to content

Commit

Permalink
add building the self hosted compiler to the main test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Jan 3, 2018
1 parent 5b15603 commit a45db7e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 4 additions & 1 deletion build.zig
Expand Up @@ -33,6 +33,8 @@ pub fn build(b: &Builder) {
docs_step.dependOn(&docgen_cmd.step);
docs_step.dependOn(&docgen_home_cmd.step);

const test_step = b.step("test", "Run all the tests");

if (findLLVM(b)) |llvm| {
// find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library
const build_info = b.exec([][]const u8{b.zig_exe, "BUILD_INFO"});
Expand Down Expand Up @@ -72,15 +74,16 @@ pub fn build(b: &Builder) {

b.default_step.dependOn(&exe.step);
b.default_step.dependOn(docs_step);
test_step.dependOn(&exe.step);

b.installArtifact(exe);
installStdLib(b);

}


const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");
const with_lldb = b.option(bool, "with-lldb", "Run tests in LLDB to get a backtrace if one fails") ?? false;
const test_step = b.step("test", "Run all the tests");

test_step.dependOn(docs_step);

Expand Down
5 changes: 5 additions & 0 deletions src-self-hosted/main.zig
Expand Up @@ -626,3 +626,8 @@ fn findZigLibDir(allocator: &mem.Allocator) -> %[]u8 {

return error.FileNotFound;
}

test "import tests" {
_ = @import("tokenizer.zig");
_ = @import("parser.zig");
}
15 changes: 13 additions & 2 deletions src-self-hosted/tokenizer.zig
Expand Up @@ -204,6 +204,7 @@ pub const Tokenizer = struct {
LineComment,
Zero,
IntegerLiteral,
IntegerLiteralWithRadix,
NumberDot,
FloatFraction,
FloatExponentUnsigned,
Expand Down Expand Up @@ -454,7 +455,7 @@ pub const Tokenizer = struct {
},
State.Zero => switch (c) {
'b', 'o', 'x' => {
state = State.IntegerLiteral;
state = State.IntegerLiteralWithRadix;
},
else => {
// reinterpret as a normal number
Expand All @@ -469,6 +470,16 @@ pub const Tokenizer = struct {
'p', 'P', 'e', 'E' => {
state = State.FloatExponentUnsigned;
},
'0'...'9' => {},
else => break,
},
State.IntegerLiteralWithRadix => switch (c) {
'.' => {
state = State.NumberDot;
},
'p', 'P' => {
state = State.FloatExponentUnsigned;
},
'0'...'9', 'a'...'f', 'A'...'F' => {},
else => break,
},
Expand All @@ -485,7 +496,7 @@ pub const Tokenizer = struct {
},
},
State.FloatFraction => switch (c) {
'p', 'P', 'e', 'E' => {
'p', 'P' => {
state = State.FloatExponentUnsigned;
},
'0'...'9', 'a'...'f', 'A'...'F' => {},
Expand Down

0 comments on commit a45db7e

Please sign in to comment.