Skip to content

Commit 5a25505

Browse files
committedNov 24, 2017
rename "parsec" to "translate-c"
1 parent afbbdb2 commit 5a25505

13 files changed

+47
-47
lines changed
 

‎CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ set(ZIG_SOURCES
339339
"${CMAKE_SOURCE_DIR}/src/target.cpp"
340340
"${CMAKE_SOURCE_DIR}/src/tokenizer.cpp"
341341
"${CMAKE_SOURCE_DIR}/src/util.cpp"
342-
"${CMAKE_SOURCE_DIR}/src/parsec.cpp"
342+
"${CMAKE_SOURCE_DIR}/src/translate_c.cpp"
343343
"${CMAKE_SOURCE_DIR}/src/zig_llvm.cpp"
344344
)
345345

‎build.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ pub fn build(b: &Builder) {
5858
test_step.dependOn(tests.addCompileErrorTests(b, test_filter));
5959
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter));
6060
test_step.dependOn(tests.addDebugSafetyTests(b, test_filter));
61-
test_step.dependOn(tests.addParseCTests(b, test_filter));
61+
test_step.dependOn(tests.addTranslateCTests(b, test_filter));
6262
}

‎ci/travis_osx_script

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ make install
2222
./zig build --build-file ../build.zig test-compile-errors --verbose
2323
./zig build --build-file ../build.zig test-asm-link --verbose
2424
./zig build --build-file ../build.zig test-debug-safety --verbose
25-
./zig build --build-file ../build.zig test-parsec --verbose
25+
./zig build --build-file ../build.zig test-translate-c --verbose

‎src-self-hosted/main.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ fn printUsage(outstream: &io.OutStream) -> %void {
208208
\\ build-exe [source] create executable from source or object files
209209
\\ build-lib [source] create library from source or object files
210210
\\ build-obj [source] create object from source or assembly
211-
\\ parsec [source] convert c code to zig code
211+
\\ translate-c [source] convert c code to zig code
212212
\\ targets list available compilation targets
213213
\\ test [source] create and run a test build
214214
\\ version print version number and exit

‎src/analyze.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type);
2828

2929
ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) {
3030
if (node->owner->c_import_node != nullptr) {
31-
// if this happens, then parsec generated code that
31+
// if this happens, then translate_c generated code that
3232
// failed semantic analysis, which isn't supposed to happen
3333
ErrorMsg *err = add_node_error(g, node->owner->c_import_node,
3434
buf_sprintf("compiler bug: @cImport generated invalid zig code"));
@@ -48,7 +48,7 @@ ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) {
4848

4949
ErrorMsg *add_error_note(CodeGen *g, ErrorMsg *parent_msg, AstNode *node, Buf *msg) {
5050
if (node->owner->c_import_node != nullptr) {
51-
// if this happens, then parsec generated code that
51+
// if this happens, then translate_c generated code that
5252
// failed semantic analysis, which isn't supposed to happen
5353

5454
Buf *note_path = buf_create_from_str("?.c");

‎src/codegen.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "ir.hpp"
1616
#include "link.hpp"
1717
#include "os.hpp"
18-
#include "parsec.hpp"
18+
#include "translate_c.hpp"
1919
#include "target.hpp"
2020
#include "zig_llvm.hpp"
2121

@@ -5353,7 +5353,7 @@ static void init(CodeGen *g) {
53535353
define_builtin_compile_vars(g);
53545354
}
53555355

5356-
void codegen_parsec(CodeGen *g, Buf *full_path) {
5356+
void codegen_translate_c(CodeGen *g, Buf *full_path) {
53575357
find_libc_include_path(g);
53585358

53595359
Buf *src_basename = buf_alloc();

‎src/codegen.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ PackageTableEntry *codegen_create_package(CodeGen *g, const char *root_src_dir,
5656
void codegen_add_assembly(CodeGen *g, Buf *path);
5757
void codegen_add_object(CodeGen *g, Buf *object_path);
5858

59-
void codegen_parsec(CodeGen *g, Buf *path);
59+
void codegen_translate_c(CodeGen *g, Buf *path);
6060

6161

6262
#endif

‎src/ir.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "ir.hpp"
1212
#include "ir_print.hpp"
1313
#include "os.hpp"
14-
#include "parsec.hpp"
14+
#include "translate_c.hpp"
1515
#include "range_set.hpp"
1616
#include "softfloat.hpp"
1717

‎src/main.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static int usage(const char *arg0) {
2323
" build-exe [source] create executable from source or object files\n"
2424
" build-lib [source] create library from source or object files\n"
2525
" build-obj [source] create object from source or assembly\n"
26-
" parsec [source] convert c code to zig code\n"
26+
" translate-c [source] convert c code to zig code\n"
2727
" targets list available compilation targets\n"
2828
" test [source] create and run a test build\n"
2929
" version print version number and exit\n"
@@ -229,7 +229,7 @@ enum Cmd {
229229
CmdTest,
230230
CmdVersion,
231231
CmdZen,
232-
CmdParseC,
232+
CmdTranslateC,
233233
CmdTargets,
234234
};
235235

@@ -632,8 +632,8 @@ int main(int argc, char **argv) {
632632
cmd = CmdVersion;
633633
} else if (strcmp(arg, "zen") == 0) {
634634
cmd = CmdZen;
635-
} else if (strcmp(arg, "parsec") == 0) {
636-
cmd = CmdParseC;
635+
} else if (strcmp(arg, "translate-c") == 0) {
636+
cmd = CmdTranslateC;
637637
} else if (strcmp(arg, "test") == 0) {
638638
cmd = CmdTest;
639639
out_type = OutTypeExe;
@@ -646,7 +646,7 @@ int main(int argc, char **argv) {
646646
} else {
647647
switch (cmd) {
648648
case CmdBuild:
649-
case CmdParseC:
649+
case CmdTranslateC:
650650
case CmdTest:
651651
if (!in_file) {
652652
in_file = arg;
@@ -703,13 +703,13 @@ int main(int argc, char **argv) {
703703

704704
switch (cmd) {
705705
case CmdBuild:
706-
case CmdParseC:
706+
case CmdTranslateC:
707707
case CmdTest:
708708
{
709709
if (cmd == CmdBuild && !in_file && objects.length == 0 && asm_files.length == 0) {
710710
fprintf(stderr, "Expected source file argument or at least one --object or --assembly argument.\n");
711711
return usage(arg0);
712-
} else if ((cmd == CmdParseC || cmd == CmdTest) && !in_file) {
712+
} else if ((cmd == CmdTranslateC || cmd == CmdTest) && !in_file) {
713713
fprintf(stderr, "Expected source file argument.\n");
714714
return usage(arg0);
715715
} else if (cmd == CmdBuild && out_type == OutTypeObj && objects.length != 0) {
@@ -719,7 +719,7 @@ int main(int argc, char **argv) {
719719

720720
assert(cmd != CmdBuild || out_type != OutTypeUnknown);
721721

722-
bool need_name = (cmd == CmdBuild || cmd == CmdParseC);
722+
bool need_name = (cmd == CmdBuild || cmd == CmdTranslateC);
723723

724724
Buf *in_file_buf = nullptr;
725725

@@ -742,7 +742,7 @@ int main(int argc, char **argv) {
742742
return usage(arg0);
743743
}
744744

745-
Buf *zig_root_source_file = (cmd == CmdParseC) ? nullptr : in_file_buf;
745+
Buf *zig_root_source_file = (cmd == CmdTranslateC) ? nullptr : in_file_buf;
746746

747747
Buf *full_cache_dir = buf_alloc();
748748
os_path_resolve(buf_create_from_str("."),
@@ -841,8 +841,8 @@ int main(int argc, char **argv) {
841841
if (timing_info)
842842
codegen_print_timing_report(g, stdout);
843843
return EXIT_SUCCESS;
844-
} else if (cmd == CmdParseC) {
845-
codegen_parsec(g, in_file_buf);
844+
} else if (cmd == CmdTranslateC) {
845+
codegen_translate_c(g, in_file_buf);
846846
ast_render(g, stdout, g->root_import->root, 4);
847847
if (timing_info)
848848
codegen_print_timing_report(g, stdout);

‎src/parsec.cpp ‎src/translate_c.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "error.hpp"
1212
#include "ir.hpp"
1313
#include "os.hpp"
14-
#include "parsec.hpp"
14+
#include "translate_c.hpp"
1515
#include "parser.hpp"
1616

1717

‎src/parsec.hpp ‎src/translate_c.hpp

File renamed without changes.

‎test/tests.zig

+24-24
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const build_examples = @import("build_examples.zig");
1818
const compile_errors = @import("compile_errors.zig");
1919
const assemble_and_link = @import("assemble_and_link.zig");
2020
const debug_safety = @import("debug_safety.zig");
21-
const parsec = @import("parsec.zig");
21+
const translate_c = @import("translate_c.zig");
2222

2323
const TestTarget = struct {
2424
os: builtin.Os,
@@ -123,16 +123,16 @@ pub fn addAssembleAndLinkTests(b: &build.Builder, test_filter: ?[]const u8) -> &
123123
return cases.step;
124124
}
125125

126-
pub fn addParseCTests(b: &build.Builder, test_filter: ?[]const u8) -> &build.Step {
127-
const cases = %%b.allocator.create(ParseCContext);
128-
*cases = ParseCContext {
126+
pub fn addTranslateCTests(b: &build.Builder, test_filter: ?[]const u8) -> &build.Step {
127+
const cases = %%b.allocator.create(TranslateCContext);
128+
*cases = TranslateCContext {
129129
.b = b,
130-
.step = b.step("test-parsec", "Run the C header file parsing tests"),
130+
.step = b.step("test-translate-c", "Run the C header file parsing tests"),
131131
.test_index = 0,
132132
.test_filter = test_filter,
133133
};
134134

135-
parsec.addCases(cases);
135+
translate_c.addCases(cases);
136136

137137
return cases.step;
138138
}
@@ -770,7 +770,7 @@ pub const BuildExamplesContext = struct {
770770
}
771771
};
772772

773-
pub const ParseCContext = struct {
773+
pub const TranslateCContext = struct {
774774
b: &build.Builder,
775775
step: &build.Step,
776776
test_index: usize,
@@ -799,17 +799,17 @@ pub const ParseCContext = struct {
799799
}
800800
};
801801

802-
const ParseCCmpOutputStep = struct {
802+
const TranslateCCmpOutputStep = struct {
803803
step: build.Step,
804-
context: &ParseCContext,
804+
context: &TranslateCContext,
805805
name: []const u8,
806806
test_index: usize,
807807
case: &const TestCase,
808808

809-
pub fn create(context: &ParseCContext, name: []const u8, case: &const TestCase) -> &ParseCCmpOutputStep {
809+
pub fn create(context: &TranslateCContext, name: []const u8, case: &const TestCase) -> &TranslateCCmpOutputStep {
810810
const allocator = context.b.allocator;
811-
const ptr = %%allocator.create(ParseCCmpOutputStep);
812-
*ptr = ParseCCmpOutputStep {
811+
const ptr = %%allocator.create(TranslateCCmpOutputStep);
812+
*ptr = TranslateCCmpOutputStep {
813813
.step = build.Step.init("ParseCCmpOutput", allocator, make),
814814
.context = context,
815815
.name = name,
@@ -821,15 +821,15 @@ pub const ParseCContext = struct {
821821
}
822822

823823
fn make(step: &build.Step) -> %void {
824-
const self = @fieldParentPtr(ParseCCmpOutputStep, "step", step);
824+
const self = @fieldParentPtr(TranslateCCmpOutputStep, "step", step);
825825
const b = self.context.b;
826826

827827
const root_src = %%os.path.join(b.allocator, b.cache_root, self.case.sources.items[0].filename);
828828

829829
var zig_args = ArrayList([]const u8).init(b.allocator);
830830
%%zig_args.append(b.zig_exe);
831831

832-
%%zig_args.append("parsec");
832+
%%zig_args.append("translate-c");
833833
%%zig_args.append(b.pathFromRoot(root_src));
834834

835835
warn("Test {}/{} {}...", self.test_index+1, self.context.test_index, self.name);
@@ -882,7 +882,7 @@ pub const ParseCContext = struct {
882882

883883
if (stderr.len != 0 and !self.case.allow_warnings) {
884884
warn(
885-
\\====== parsec emitted warnings: ============
885+
\\====== translate-c emitted warnings: =======
886886
\\{}
887887
\\============================================
888888
\\
@@ -914,7 +914,7 @@ pub const ParseCContext = struct {
914914
warn("\n");
915915
}
916916

917-
pub fn create(self: &ParseCContext, allow_warnings: bool, filename: []const u8, name: []const u8,
917+
pub fn create(self: &TranslateCContext, allow_warnings: bool, filename: []const u8, name: []const u8,
918918
source: []const u8, expected_lines: ...) -> &TestCase
919919
{
920920
const tc = %%self.b.allocator.create(TestCase);
@@ -932,37 +932,37 @@ pub const ParseCContext = struct {
932932
return tc;
933933
}
934934

935-
pub fn add(self: &ParseCContext, name: []const u8, source: []const u8, expected_lines: ...) {
935+
pub fn add(self: &TranslateCContext, name: []const u8, source: []const u8, expected_lines: ...) {
936936
const tc = self.create(false, "source.h", name, source, expected_lines);
937937
self.addCase(tc);
938938
}
939939

940-
pub fn addC(self: &ParseCContext, name: []const u8, source: []const u8, expected_lines: ...) {
940+
pub fn addC(self: &TranslateCContext, name: []const u8, source: []const u8, expected_lines: ...) {
941941
const tc = self.create(false, "source.c", name, source, expected_lines);
942942
self.addCase(tc);
943943
}
944944

945-
pub fn addAllowWarnings(self: &ParseCContext, name: []const u8, source: []const u8, expected_lines: ...) {
945+
pub fn addAllowWarnings(self: &TranslateCContext, name: []const u8, source: []const u8, expected_lines: ...) {
946946
const tc = self.create(true, "source.h", name, source, expected_lines);
947947
self.addCase(tc);
948948
}
949949

950-
pub fn addCase(self: &ParseCContext, case: &const TestCase) {
950+
pub fn addCase(self: &TranslateCContext, case: &const TestCase) {
951951
const b = self.b;
952952

953-
const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "parsec {}", case.name);
953+
const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "translate-c {}", case.name);
954954
if (self.test_filter) |filter| {
955955
if (mem.indexOf(u8, annotated_case_name, filter) == null)
956956
return;
957957
}
958958

959-
const parsec_and_cmp = ParseCCmpOutputStep.create(self, annotated_case_name, case);
960-
self.step.dependOn(&parsec_and_cmp.step);
959+
const translate_c_and_cmp = TranslateCCmpOutputStep.create(self, annotated_case_name, case);
960+
self.step.dependOn(&translate_c_and_cmp.step);
961961

962962
for (case.sources.toSliceConst()) |src_file| {
963963
const expanded_src_path = %%os.path.join(b.allocator, b.cache_root, src_file.filename);
964964
const write_src = b.addWriteFile(expanded_src_path, src_file.source);
965-
parsec_and_cmp.step.dependOn(&write_src.step);
965+
translate_c_and_cmp.step.dependOn(&write_src.step);
966966
}
967967
}
968968
};

‎test/parsec.zig ‎test/translate_c.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const tests = @import("tests.zig");
22

3-
pub fn addCases(cases: &tests.ParseCContext) {
3+
pub fn addCases(cases: &tests.TranslateCContext) {
44
cases.addAllowWarnings("simple data types",
55
\\#include <stdint.h>
66
\\int foo(char a, unsigned char b, signed char c);

0 commit comments

Comments
 (0)
Please sign in to comment.