Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 28c0c79

Browse files
committed
add codegen for lib-ruby-parser.hpp
1 parent 6933e8e commit 28c0c79

Some content is hidden

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

43 files changed

+185
-141
lines changed

.depend

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ api.o: api.cpp api.hpp parser_options.hpp string.hpp decoder.hpp \
77
nodes.hpp diagnostic.hpp messages.hpp comment.hpp magic_comment.hpp \
88
utils.hpp test_helper.hpp
99

10-
blobs.o: blobs.cpp
11-
1210
bytes.o: bytes.cpp bytes.hpp utils.hpp test_helper.hpp
1311

1412
comment.o: comment.cpp utils.hpp comment.hpp loc.hpp decoded_input.hpp \

.github/workflows/test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,25 @@ jobs:
9797
9898
- name: run tests
9999
run: ${{ matrix.build.run }}
100+
101+
test-header:
102+
name: test building lib-ruby-parser.hpp
103+
runs-on: ubuntu-latest
104+
env:
105+
TARGET: x86_64-unknown-linux-gnu
106+
steps:
107+
- name: install rust
108+
uses: actions-rs/toolchain@v1
109+
with:
110+
profile: minimal
111+
toolchain: stable
112+
override: true
113+
114+
- name: checkout
115+
uses: actions/checkout@v2
116+
117+
- name: build lib-ruby-parser.hpp
118+
run: make lib-ruby-parser.hpp
119+
120+
- name: validate lib-ruby-parser.hpp
121+
run: clang++ -fsyntax-only -Wall -Wextra -Wpedantic lib-ruby-parser.hpp

api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace lib_ruby_parser
2121
}
2222
}
2323

24-
// #ifdef TEST_ENV
24+
#ifdef TEST_ENV
2525

2626
#include "test_helper.hpp"
2727

@@ -58,4 +58,4 @@ namespace lib_ruby_parser
5858
}
5959
}
6060

61-
// #endif
61+
#endif

api.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace lib_ruby_parser
1212
*/
1313
ParserResult parse(ParserOptions options, ByteList input);
1414

15-
// #ifdef TEST_ENV
15+
#ifdef TEST_ENV
1616
void run_test_group_api(void);
17-
// #endif
18-
}
17+
#endif
18+
} // namespace lib_ruby_parser
1919

2020
#endif // LIB_RUBY_PARSER_API_HPP

bytes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace lib_ruby_parser
2828
Bytes::Bytes(ByteList raw_) : raw(std::move(raw_)) {}
2929
} // namespace lib_ruby_parser
3030

31-
// #ifdef TEST_ENV
31+
#ifdef TEST_ENV
3232

3333
#include "test_helper.hpp"
3434
#include <cstdlib>
@@ -94,4 +94,4 @@ namespace lib_ruby_parser
9494

9595
}
9696

97-
// #endif
97+
#endif

bytes.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ namespace lib_ruby_parser
4848
Bytes &operator=(Bytes &&) = default;
4949
};
5050

51-
// #ifdef TEST_ENV
51+
#ifdef TEST_ENV
5252
void run_test_group_bytes(void);
53-
// #endif
53+
#endif
5454

5555
} // namespace lib_ruby_parser
5656

codegen/build.mk

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ CODEGEN_DEPS += codegen/build.rs
1212
DO_CODEGEN = cd codegen && cargo build
1313

1414
# Codegen deps
15-
messages.c: $(CODEGEN_DEPS)
15+
messages.cpp: $(CODEGEN_DEPS)
1616
$(DO_CODEGEN)
17-
CLEAN += messages.c
17+
CLEAN += messages.cpp
1818

19-
messages.h: $(CODEGEN_DEPS)
19+
messages.hpp: $(CODEGEN_DEPS)
2020
$(DO_CODEGEN)
21-
CLEAN += messages.h
21+
CLEAN += messages.hpp
2222

23-
nodes.c: $(CODEGEN_DEPS)
23+
nodes.cpp: $(CODEGEN_DEPS)
2424
$(DO_CODEGEN)
25-
CLEAN += nodes.c
25+
CLEAN += nodes.cpp
2626

27-
nodes.h: $(CODEGEN_DEPS)
27+
nodes.hpp: $(CODEGEN_DEPS)
2828
$(DO_CODEGEN)
29-
CLEAN += nodes.h
29+
CLEAN += nodes.hpp
3030

3131
ruby-parser-c/src/node.rs: $(CODEGEN_DEPS)
3232
$(DO_CODEGEN)
@@ -48,8 +48,7 @@ update-depend: token_ids.hpp
4848
lib-ruby-parser.hpp: codegen/examples/merge_headers.rs $(HPP_FILES) token_ids.hpp
4949
cargo run --example merge_headers --manifest-path codegen/Cargo.toml
5050
CLEAN += lib-ruby-parser.hpp
51-
# update-depend: lib-ruby-parser.hpp
52-
# FIXME
51+
update-depend: lib-ruby-parser.hpp
5352

5453
# manual codegen task
5554
do-codegen:

codegen/codegen/messages_cpp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace lib_ruby_parser
6363
{{ end }}
6464
} // namespace lib_ruby_parser
6565
66-
// #ifdef TEST_ENV
66+
#ifdef TEST_ENV
6767
6868
#include \"test_helper.hpp\"
6969
@@ -133,7 +133,7 @@ namespace lib_ruby_parser {
133133
}
134134
}
135135
136-
// #endif
136+
#endif
137137
";
138138

139139
pub(crate) fn codegen() {

codegen/codegen/messages_hpp.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const TEMPLATE: &str = "#ifndef LIB_RUBY_PARSER_MESSAGES_HPP
88
#include <cstdint>
99
#include \"string.hpp\"
1010
11-
namespace lib_ruby_parser {
11+
namespace lib_ruby_parser
12+
{
1213
{{ each message }}<dnl>
1314
{{ helper message-comment }}
1415
class {{ helper message-camelcase-name }}
@@ -94,10 +95,10 @@ namespace lib_ruby_parser {
9495
DiagnosticMessageList &operator=(DiagnosticMessageList &&);
9596
};
9697
97-
// #ifdef TEST_ENV
98+
#ifdef TEST_ENV
9899
void run_test_group_message(void);
99-
// #endif
100-
}
100+
#endif
101+
} // namespace lib_ruby_parser
101102
102103
#endif // LIB_RUBY_PARSER_MESSAGES_HPP
103104
";

codegen/codegen/nodes_cpp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace lib_ruby_parser
4747
LIST_IMPL(NodeList, Node, LIB_RUBY_PARSER_drop_node_list);
4848
} // namespace lib_ruby_parser
4949
50-
// #ifdef TEST_ENV
50+
#ifdef TEST_ENV
5151
5252
#include \"test_helper.hpp\"
5353
@@ -133,7 +133,7 @@ namespace lib_ruby_parser {
133133
}
134134
} // namespace lib_ruby_parser
135135
136-
// #endif
136+
#endif
137137
";
138138

139139
pub(crate) fn codegen() {

0 commit comments

Comments
 (0)