Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] New Zig formal grammar #1685

Merged
merged 25 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e5a8135
Reverted #1628
Hejsil Oct 27, 2018
0de46ff
Changed code in places where the new syntax doesn't compile
Hejsil Oct 27, 2018
42a1bb2
Revert "Changed code in places where the new syntax doesn't compile"
Hejsil Oct 30, 2018
37b48dc
Revert "Changed code in places where the new syntax doesn't compile"
Hejsil Oct 30, 2018
db5d479
New proposed changes
Hejsil Oct 30, 2018
43b7586
Merge branch 'new-grammar' of github.com:ziglang/zig into new-grammar
Hejsil Nov 1, 2018
77581a9
Rewriting the stage 1 parse with the new grammar in mind. Part 1
Hejsil Nov 1, 2018
246df67
Parsing if statements
Hejsil Nov 1, 2018
f54c5aa
Declared all functions required to parse the Zig grammar.
Hejsil Nov 2, 2018
66fccc1
Parsing most expressions
Hejsil Nov 7, 2018
6a82b9e
Removed most result structs, in favor of the types in all_types.h
Hejsil Nov 8, 2018
d6da304
Parsing all binary operators
Hejsil Nov 8, 2018
b841efb
We have a parser that compiles
Hejsil Nov 9, 2018
d2555e2
Fixed parser bugs
Hejsil Nov 9, 2018
f4d5ee5
Adapted code to have root be a container decl
Hejsil Nov 9, 2018
e9ab2e6
We have a lot of tests passing now!
Hejsil Nov 9, 2018
0ecb1c6
Merge branch 'master' into new-grammar
Hejsil Nov 9, 2018
3824930
Code not compiling after merge
Hejsil Nov 9, 2018
36d32f6
Fixed some tests, line numbering and percedence issues
Hejsil Nov 12, 2018
a50a7dd
All stage1 tests succeeds!
Hejsil Nov 12, 2018
2640719
Implemented the last syntax changes for if/for/while in return type
Hejsil Nov 13, 2018
ab9408f
Implemented anyerror syntax in stage2
Hejsil Nov 13, 2018
605e870
zig fmt
Hejsil Nov 13, 2018
3f7cb65
Fixed last tests failing
Hejsil Nov 13, 2018
9adaea8
Updated comment to reflect grammar
Hejsil Nov 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn build(b: *Builder) !void {

const rel_zig_exe = try os.path.relative(b.allocator, b.build_root, b.zig_exe);
const langref_out_path = os.path.join(b.allocator, b.cache_root, "langref.html") catch unreachable;
var docgen_cmd = b.addCommand(null, b.env_map, [][]const u8.{
var docgen_cmd = b.addCommand(null, b.env_map, [][]const u8{
docgen_exe.getOutputPath(),
rel_zig_exe,
"doc" ++ os.path.sep_str ++ "langref.html.in",
Expand All @@ -31,12 +31,12 @@ pub fn build(b: *Builder) !void {
const test_step = b.step("test", "Run all the tests");

// find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library
const build_info = try b.exec([][]const u8.{
const build_info = try b.exec([][]const u8{
b.zig_exe,
"BUILD_INFO",
});
var index: usize = 0;
var ctx = Context.{
var ctx = Context{
.cmake_binary_dir = nextValue(&index, build_info),
.cxx_compiler = nextValue(&index, build_info),
.llvm_config_exe = nextValue(&index, build_info),
Expand Down Expand Up @@ -162,7 +162,7 @@ fn addCppLib(b: *Builder, lib_exe_obj: var, cmake_binary_dir: []const u8, lib_na
lib_exe_obj.addObjectFile(os.path.join(b.allocator, cmake_binary_dir, "zig_cpp", b.fmt("{}{}{}", lib_prefix, lib_name, lib_exe_obj.target.libFileExt())) catch unreachable);
}

const LibraryDep = struct.{
const LibraryDep = struct {
prefix: []const u8,
libdirs: ArrayList([]const u8),
libs: ArrayList([]const u8),
Expand All @@ -171,24 +171,24 @@ const LibraryDep = struct.{
};

fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {
const shared_mode = try b.exec([][]const u8.{ llvm_config_exe, "--shared-mode" });
const shared_mode = try b.exec([][]const u8{ llvm_config_exe, "--shared-mode" });
const is_static = mem.startsWith(u8, shared_mode, "static");
const libs_output = if (is_static)
try b.exec([][]const u8.{
try b.exec([][]const u8{
llvm_config_exe,
"--libfiles",
"--system-libs",
})
else
try b.exec([][]const u8.{
try b.exec([][]const u8{
llvm_config_exe,
"--libs",
});
const includes_output = try b.exec([][]const u8.{ llvm_config_exe, "--includedir" });
const libdir_output = try b.exec([][]const u8.{ llvm_config_exe, "--libdir" });
const prefix_output = try b.exec([][]const u8.{ llvm_config_exe, "--prefix" });
const includes_output = try b.exec([][]const u8{ llvm_config_exe, "--includedir" });
const libdir_output = try b.exec([][]const u8{ llvm_config_exe, "--libdir" });
const prefix_output = try b.exec([][]const u8{ llvm_config_exe, "--prefix" });

var result = LibraryDep.{
var result = LibraryDep{
.prefix = mem.split(prefix_output, " \r\n").next().?,
.libs = ArrayList([]const u8).init(b.allocator),
.system_libs = ArrayList([]const u8).init(b.allocator),
Expand Down Expand Up @@ -328,7 +328,7 @@ fn addCxxKnownPath(
objname: []const u8,
errtxt: ?[]const u8,
) !void {
const path_padded = try b.exec([][]const u8.{
const path_padded = try b.exec([][]const u8{
ctx.cxx_compiler,
b.fmt("-print-file-name={}", objname),
});
Expand All @@ -344,7 +344,7 @@ fn addCxxKnownPath(
exe.addObjectFile(path_unpadded);
}

const Context = struct.{
const Context = struct {
cmake_binary_dir: []const u8,
cxx_compiler: []const u8,
llvm_config_exe: []const u8,
Expand Down
Loading