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

Commit c02a6db

Browse files
committed
codegen token_ids.h with a new codegen binary that has {{ tokens }} variable now
1 parent 6466775 commit c02a6db

File tree

5 files changed

+18
-27
lines changed

5 files changed

+18
-27
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ jobs:
7171
- name: checkout
7272
uses: actions/checkout@v2
7373

74-
- name: codegen
75-
env:
76-
RUSTFLAGS: ""
77-
run: |
78-
make do-codegen
79-
make token_ids.h
80-
8174
- name: make lib file
8275
run: |
8376
make ${{ matrix.build.lib_file }}

.github/workflows/test.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,6 @@ jobs:
100100
- name: checkout
101101
uses: actions/checkout@v2
102102

103-
- name: codegen
104-
env:
105-
RUSTFLAGS: ""
106-
run: |
107-
make do-codegen
108-
make token_ids.h
109-
110103
- name: run tests
111104
run: ${{ matrix.build.run }}
112105

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ H_FILES = alloc.h \
2525
parser_result.h \
2626
source_line.h \
2727
token.h \
28+
token_ids.h \
2829
token_rewriter.h
2930
O_FILES = $(foreach source,$(SOURCES),$(source).$(O))
3031
STATIC_LIB = libruby_parser_c.$(A)

codegen/build.mk

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ URL="$(1)" SAVE_AS="$(2)" ruby scripts/download_file.rb
33
endef
44

55
CODEGEN_EXE = codegen/codegen$(EXE)
6-
76
$(CODEGEN_EXE):
8-
$(call download_file, https://github.com/lib-ruby-parser/nodes/releases/download/v0.52.0/codegen-$(TARGET)$(EXE), $@)
7+
$(call download_file, https://github.com/lib-ruby-parser/lib-ruby-parser/releases/download/v4.0.2+ruby-3.1.1/codegen-$(TARGET)$(EXE), $@)
98
chmod +x $(CODEGEN_EXE)
109
CLEAN += $(CODEGEN_EXE)
1110

@@ -34,13 +33,9 @@ ruby-parser-c/src/message.rs: codegen/messages.rs.liquid $(CODEGEN_EXE)
3433
$(CODEGEN_EXE) --template $< --write-to $@
3534
CLEAN += ruby-parser-c/src/message.rs
3635

37-
# token_id.{h,c} codegen
38-
DO_CODEGEN_TOKEN_IDS = cargo run --example build_token_ids --manifest-path codegen/Cargo.toml
39-
40-
token_ids.h: codegen/examples/build_token_ids.rs
41-
$(DO_CODEGEN_TOKEN_IDS)
36+
token_ids.h: codegen/token_ids.h.liquid $(CODEGEN_EXE)
37+
$(CODEGEN_EXE) --template $< --write-to $@
4238
CLEAN += token_ids.h
43-
update-depend: token_ids.h
4439

4540
merge-headers:
4641
wget -q https://github.com/iliabylich/merge_headers/releases/download/v1.0.0/merge-headers-$(TARGET) -O merge-headers
@@ -60,14 +55,10 @@ join-with = $(subst $(space),$1,$(strip $2))
6055
lib-ruby-parser.h: merge-headers $(H_FILES) token_ids.h nodes.h messages.h
6156
./merge-headers \
6257
--cc $(CC) \
63-
--headers "$(call join-with,;,$(H_FILES));token_ids.h" \
58+
--headers "$(call join-with,;,$(H_FILES))" \
6459
--write-to lib-ruby-parser.h \
6560
--include-guard-prefix LIB_RUBY_PARSER_ \
6661
--output-guard LIB_RUBY_PARSER_H
6762

6863
CLEAN += lib-ruby-parser.h
6964
update-depend: lib-ruby-parser.h
70-
71-
# manual codegen task
72-
do-codegen:
73-
$(DO_CODEGEN)

codegen/token_ids.h.liquid

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef LIB_RUBY_PARSER_TOKEN_IDS_H
2+
#define LIB_RUBY_PARSER_TOKEN_IDS_H
3+
4+
/// @defgroup token_ids Token IDs
5+
/// @{
6+
/// @}
7+
8+
{% for token in tokens %}
9+
/// {{ token.comment }}
10+
#define LIB_RUBY_PARSER_TOKEN_{{ token.name }} {{ token.value }}
11+
{% endfor %}
12+
13+
#endif // LIB_RUBY_PARSER_TOKEN_IDS_H

0 commit comments

Comments
 (0)