Skip to content

Commit 64a5efb

Browse files
committed
Faster checktestdata with antlr and template hell.
1 parent b281d3f commit 64a5efb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1725
-8609
lines changed

.clang-format

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
BasedOnStyle: Google
2+
DerivePointerAlignment: false
3+
PointerAlignment: Left

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ cov-int/
1717
*.gcda
1818
*.gcno
1919
coverage*.html
20+
/bazel-*
21+
*.swp

BUILD

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
genrule(
2+
name = "generated",
3+
srcs = ["checktestdata.g4"],
4+
outs = [
5+
"checktestdataBaseListener.cpp",
6+
"checktestdataBaseListener.h",
7+
"checktestdataLexer.cpp",
8+
"checktestdataLexer.h",
9+
"checktestdataListener.cpp",
10+
"checktestdataListener.h",
11+
"checktestdataParser.cpp",
12+
"checktestdataParser.h",
13+
],
14+
cmd = "$(location :antlr4) -Dlanguage=Cpp -o $(@D) checktestdata.g4",
15+
tools = [":antlr4"],
16+
)
17+
18+
java_binary(
19+
name = "antlr4",
20+
main_class = "org.antlr.v4.Tool",
21+
runtime_deps = [
22+
"@antlr4//jar",
23+
],
24+
)
25+
26+
cc_library(
27+
name = "parser",
28+
srcs = [":generated"],
29+
deps = [
30+
"@antlr4_cpp_runtime//:runtime",
31+
],
32+
)
33+
34+
cc_binary(
35+
name = "checktestdata",
36+
srcs = ["checktestdata.cc"],
37+
deps = [
38+
":command",
39+
":expression",
40+
":parser",
41+
":stream",
42+
":value",
43+
":variable",
44+
"@com_google_absl//absl/strings",
45+
"@re2",
46+
],
47+
)
48+
49+
cc_library(
50+
name = "stream",
51+
hdrs = ["stream.h"],
52+
)
53+
54+
cc_library(
55+
name = "expression",
56+
srcs = ["expression.cc"],
57+
hdrs = ["expression.h"],
58+
deps = [
59+
":parser",
60+
":value",
61+
":variable",
62+
"@com_google_absl//absl/strings",
63+
],
64+
)
65+
66+
cc_library(
67+
name = "value",
68+
srcs = ["value.cc"],
69+
hdrs = ["value.h"],
70+
linkopts = [
71+
"-lgmp",
72+
],
73+
deps = [
74+
":parser",
75+
"@com_google_absl//absl/strings",
76+
],
77+
)
78+
79+
cc_library(
80+
name = "variable",
81+
srcs = ["variable.cc"],
82+
hdrs = ["variable.h"],
83+
deps = [
84+
":parser",
85+
":value",
86+
"@cpp_btree//:btree_map",
87+
],
88+
)
89+
90+
cc_library(
91+
name = "command",
92+
srcs = [],
93+
hdrs = ["command.h"],
94+
)

BUILD.antlr4_cpp_runtime

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cc_library(
2+
name = "runtime",
3+
srcs = glob(["runtime/src/**/*.cpp"]),
4+
hdrs = glob(["runtime/src/**/*.h"]),
5+
includes = [
6+
"runtime/src",
7+
"runtime/src/atn",
8+
"runtime/src/support",
9+
"runtime/src/tree",
10+
],
11+
visibility = ["//visibility:public"],
12+
)

BUILD.cpp_btree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cc_library(
2+
name = "btree",
3+
hdrs = [
4+
"btree.h",
5+
"btree_container.h"
6+
],
7+
)
8+
9+
cc_library(
10+
name = "btree_map",
11+
hdrs = ["btree_map.h"],
12+
deps = [":btree"],
13+
visibility = ["//visibility:public"],
14+
)

COPYING

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2008 - 2017 by the checktestdata developers and all respective
1+
Copyright (c) 2008 - 2018 by the checktestdata developers and all respective
22
contributors. All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

Makefile

Lines changed: 0 additions & 140 deletions
This file was deleted.

WORKSPACE

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
http_jar(
2+
name = "antlr4",
3+
sha256 = "f41dce7441d523baf9769cb7756a00f27a4b67e55aacab44525541f62d7f6688",
4+
url = "https://www.antlr.org/download/antlr-4.7.1-complete.jar",
5+
)
6+
7+
new_http_archive(
8+
name = "antlr4_cpp_runtime",
9+
build_file = "BUILD.antlr4_cpp_runtime",
10+
sha256 = "4d0714f441333a63e50031c9e8e4890c78f3d21e053d46416949803e122a6574",
11+
strip_prefix = "antlr4-4.7.1/runtime/Cpp",
12+
url = "https://github.com/antlr/antlr4/archive/4.7.1.tar.gz",
13+
)
14+
15+
http_archive(
16+
name = "re2",
17+
sha256 = "15818006416421edb583f8f1502e77eca3338bb3c19925226a7e5b65e746f279",
18+
strip_prefix = "re2-25bfefa0eefb53aa3ea28d26194f10362ec4cab3",
19+
url = "https://github.com/google/re2/archive/25bfefa0eefb53aa3ea28d26194f10362ec4cab3.tar.gz",
20+
)
21+
22+
http_archive(
23+
name = "com_google_absl",
24+
sha256 = "80f5da966b977cd36127c9614074b16e2d3a74e9066d6ee91c7916d798faa333",
25+
strip_prefix = "abseil-cpp-e5be80532b5d998813f9db952d2cc5401b1532df",
26+
url = "https://github.com/abseil/abseil-cpp/archive/e5be80532b5d998813f9db952d2cc5401b1532df.tar.gz",
27+
)
28+
29+
new_http_archive(
30+
name = "cpp_btree",
31+
build_file = "BUILD.cpp_btree",
32+
sha256 = "e86d047ef509d70f706d526301dc64b6935826d38649f834de49cd11a3018d01",
33+
strip_prefix = "cpp-btree-92ec61e4b8bf182c5c49ebf6540dac62d569d090",
34+
url = "https://github.com/algorithm-ninja/cpp-btree/archive/92ec61e4b8bf182c5c49ebf6540dac62d569d090.tar.gz",
35+
)

bootstrap

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)