rbs 4.1.3-java → 4.2.0.pre.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitattributes +1 -0
- data/.github/workflows/bundle-update.yml +2 -2
- data/.github/workflows/c-check.yml +2 -2
- data/.github/workflows/changelog.yml +121 -0
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/jruby.yml +3 -3
- data/.github/workflows/release-gems.yml +6 -7
- data/.github/workflows/ruby.yml +6 -6
- data/.github/workflows/rust.yml +12 -12
- data/.github/workflows/truffleruby.yml +2 -2
- data/.github/workflows/typecheck.yml +2 -2
- data/.github/workflows/wasm.yml +3 -3
- data/.github/workflows/windows.yml +2 -2
- data/CHANGELOG.md +27 -0
- data/Rakefile +50 -21
- data/config.yml +5 -0
- data/docs/CONTRIBUTING.md +1 -1
- data/docs/release.md +57 -1
- data/docs/stdlib.md +8 -0
- data/docs/syntax.md +12 -0
- data/ext/rbs_extension/ast_translation.c +15 -0
- data/ext/rbs_extension/class_constants.c +2 -0
- data/ext/rbs_extension/class_constants.h +1 -0
- data/ext/rbs_extension/main.c +55 -19
- data/include/rbs/ast.h +21 -13
- data/include/rbs/defines.h +2 -2
- data/include/rbs/lexer.h +13 -12
- data/include/rbs/parser.h +37 -3
- data/lib/rbs/ast/declarations.rb +1 -1
- data/lib/rbs/ast/type_param.rb +1 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +8 -5
- data/lib/rbs/definition_builder/method_builder.rb +4 -4
- data/lib/rbs/definition_builder.rb +5 -2
- data/lib/rbs/environment/class_entry.rb +12 -0
- data/lib/rbs/environment/module_entry.rb +26 -1
- data/lib/rbs/parser_aux.rb +2 -2
- data/lib/rbs/types.rb +44 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/wasm/parser.rb +62 -25
- data/lib/rbs/wasm/rbs_parser.wasm +0 -0
- data/lib/rbs/wasm/runtime.rb +19 -4
- data/lib/rbs/wasm/serialization_schema.rb +3 -2
- data/schema/function.json +12 -1
- data/sig/environment/class_entry.rbs +6 -0
- data/sig/environment/module_entry.rbs +15 -0
- data/sig/parser.rbs +4 -4
- data/sig/types.rbs +11 -1
- data/src/ast.c +17 -1
- data/src/lexer.c +1562 -1560
- data/src/lexer.re +50 -18
- data/src/lexstate.c +2 -1
- data/src/parser.c +130 -70
- data/src/serialize.c +20 -13
- data/src/util/rbs_encoding.c +195 -49
- data/wasm/README.md +20 -4
- data/wasm/rbs_wasm.c +93 -37
- metadata +3 -1
data/src/lexer.re
CHANGED
|
@@ -16,7 +16,19 @@ rbs_token_t rbs_lexer_next_token(rbs_lexer_t *lexer) {
|
|
|
16
16
|
re2c:define:YYRESTORE = "*lexer = backup;";
|
|
17
17
|
re2c:yyfill:enable = 0;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// Ruby's rule for what an identifier is made of is `ISALNUM(c) ||
|
|
20
|
+
// (c) == '_' || !ISASCII(c)`, so define the class by what it leaves
|
|
21
|
+
// out: every ASCII character that is not a word character, and the
|
|
22
|
+
// sentinel `rbs_next_char` reports for a byte that is invalid under
|
|
23
|
+
// the active encoding. Everything else can appear in an identifier,
|
|
24
|
+
// which is how a non-ASCII character gets in.
|
|
25
|
+
ident_char = . \ ([\x00-\x7F] \ [a-zA-Z0-9_]) \ [\uFFFD];
|
|
26
|
+
|
|
27
|
+
// An ASCII digit cannot lead an identifier, but a non-ASCII one can --
|
|
28
|
+
// Ruby accepts a name made of full-width digits. Since `rbs_next_char`
|
|
29
|
+
// never reports a non-ASCII character as `[0-9]`, subtracting the ASCII
|
|
30
|
+
// digits from `ident_char` is the whole of that rule.
|
|
31
|
+
ident_start = ident_char \ [0-9];
|
|
20
32
|
|
|
21
33
|
operator = "/" | "~" | "[]=" | "!" | "!=" | "!~" | "-" | "-@" | "+" | "+@"
|
|
22
34
|
| "==" | "===" | "=~" | "<<" | "<=" | "<=>" | ">" | ">=" | ">>" | "%";
|
|
@@ -59,6 +71,15 @@ rbs_token_t rbs_lexer_next_token(rbs_lexer_t *lexer) {
|
|
|
59
71
|
"%a<" [^>\x00]* ">" { return rbs_next_token(lexer, tANNOTATION); }
|
|
60
72
|
|
|
61
73
|
"#" (. \ [\x00\uFFFD])* {
|
|
74
|
+
// Keep a bare CR in the comment, but leave the CR in CRLF for a trivia token.
|
|
75
|
+
if (rbs_peek(lexer) == '\n' && lexer->string.start[lexer->current.byte_pos - 1] == '\r') {
|
|
76
|
+
lexer->current.byte_pos -= 1;
|
|
77
|
+
lexer->current.char_pos -= 1;
|
|
78
|
+
lexer->current.column -= 1;
|
|
79
|
+
lexer->current_code_point = '\r';
|
|
80
|
+
lexer->current_character_bytes = 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
62
83
|
return rbs_next_token(
|
|
63
84
|
lexer,
|
|
64
85
|
lexer->first_token_of_line ? tLINECOMMENT : tCOMMENT
|
|
@@ -116,7 +137,6 @@ rbs_token_t rbs_lexer_next_token(rbs_lexer_t *lexer) {
|
|
|
116
137
|
":" dqstring { return rbs_next_token(lexer, tDQSYMBOL); }
|
|
117
138
|
":" sqstring { return rbs_next_token(lexer, tSQSYMBOL); }
|
|
118
139
|
|
|
119
|
-
identifier = [a-zA-Z_] word* [!?=]?;
|
|
120
140
|
symbol_opr = ":|" | ":&" | ":/" | ":%" | ":~" | ":`" | ":^"
|
|
121
141
|
| ":==" | ":=~" | ":===" | ":!" | ":!=" | ":!~"
|
|
122
142
|
| ":<" | ":<=" | ":<<" | ":<=>" | ":>" | ":>=" | ":>>"
|
|
@@ -127,22 +147,34 @@ rbs_token_t rbs_lexer_next_token(rbs_lexer_t *lexer) {
|
|
|
127
147
|
| [~*$?!@\\/;,.=:<>"&'`+]
|
|
128
148
|
| [^ \t\r\n:;=.,!"$%&()-+~|\\'[\]{}*/<>^\x00]+;
|
|
129
149
|
|
|
130
|
-
":"
|
|
131
|
-
"
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
[a-
|
|
137
|
-
[A-Z]
|
|
138
|
-
"_"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
150
|
+
":" "@"{0,2} ident_start ident_char* [!?=]? { return rbs_next_token(lexer, tSYMBOL); }
|
|
151
|
+
":$" global_ident { return rbs_next_token(lexer, tSYMBOL); }
|
|
152
|
+
symbol_opr { return rbs_next_token(lexer, tSYMBOL); }
|
|
153
|
+
|
|
154
|
+
[a-z] ident_char* { return rbs_next_token(lexer, tLIDENT); }
|
|
155
|
+
[A-Z] ident_char* { return rbs_next_token(lexer, tUIDENT); }
|
|
156
|
+
"_" [a-z0-9_] ident_char* { return rbs_next_token(lexer, tULLIDENT); }
|
|
157
|
+
"_" [A-Z] ident_char* { return rbs_next_token(lexer, tULIDENT); }
|
|
158
|
+
"_" { return rbs_next_token(lexer, tULLIDENT); }
|
|
159
|
+
|
|
160
|
+
// Every ASCII spelling is covered by one of the rules above, which match
|
|
161
|
+
// exactly as far, and re2c settles a tie of equal length in favour of the
|
|
162
|
+
// rule written first. So this one is left with the names that open with a
|
|
163
|
+
// character outside ASCII.
|
|
164
|
+
//
|
|
165
|
+
// RBS reads the case of that character to tell a class name from an alias
|
|
166
|
+
// name, and outside ASCII there is no reading of it that both the lexer
|
|
167
|
+
// and `TypeName#kind` can agree on. Those names get a token of their own
|
|
168
|
+
// and the parser takes it only where the question does not come up.
|
|
169
|
+
ident_start ident_char* { return rbs_next_token(lexer, tNONASCIIIDENT); }
|
|
170
|
+
|
|
171
|
+
// None of these four needs to know the case of the first character, so
|
|
172
|
+
// widening the leading position to `ident_start` is all they need.
|
|
173
|
+
ident_start ident_char* "!" { return rbs_next_token(lexer, tBANGIDENT); }
|
|
174
|
+
ident_start ident_char* "=" { return rbs_next_token(lexer, tEQIDENT); }
|
|
175
|
+
|
|
176
|
+
"@" ident_start ident_char* { return rbs_next_token(lexer, tAIDENT); }
|
|
177
|
+
"@@" ident_start ident_char* { return rbs_next_token(lexer, tA2IDENT); }
|
|
146
178
|
|
|
147
179
|
"$" global_ident { return rbs_next_token(lexer, tGIDENT); }
|
|
148
180
|
|
data/src/lexstate.c
CHANGED
|
@@ -74,6 +74,7 @@ static const char *RBS_TOKENTYPE_NAMES[] = {
|
|
|
74
74
|
"tUIDENT", /* Identifiers starting with upper case */
|
|
75
75
|
"tULIDENT", /* Identifiers starting with `_` */
|
|
76
76
|
"tULLIDENT",
|
|
77
|
+
"tNONASCIIIDENT",
|
|
77
78
|
"tGIDENT", /* Identifiers starting with `$` */
|
|
78
79
|
"tAIDENT", /* Identifiers starting with `@` */
|
|
79
80
|
"tA2IDENT", /* Identifiers starting with `@@` */
|
|
@@ -119,7 +120,7 @@ unsigned int rbs_peek(rbs_lexer_t *lexer) {
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
bool rbs_next_char(rbs_lexer_t *lexer, unsigned int *codepoint, size_t *byte_len) {
|
|
122
|
-
if (RBS_UNLIKELY(lexer->current.byte_pos
|
|
123
|
+
if (RBS_UNLIKELY(lexer->current.byte_pos >= lexer->end_pos)) {
|
|
123
124
|
return false;
|
|
124
125
|
}
|
|
125
126
|
|