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

Commit fec5aec

Browse files
committed
update to lib-ruby-parser 3.0.0-8
1 parent 7dfa7c3 commit fec5aec

File tree

13 files changed

+87
-2
lines changed

13 files changed

+87
-2
lines changed

.depend

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,27 @@ target/debug/token_rewriter.o: src/token_rewriter.cpp \
5858
src/token_rewriter.h src/token.h src/bytes.h src/byte_ptr.h src/loc.h \
5959
src/input.h
6060

61+
target/debug/gen/messages/classes.o: src/gen/messages/classes.cpp \
62+
src/gen/messages/classes.h src/gen/messages/../../bytes.h \
63+
src/gen/messages/../../byte_ptr.h
64+
65+
target/debug/gen/messages/make.o: src/gen/messages/make.cpp \
66+
src/gen/messages/make.h src/gen/messages/../../error_level.h \
67+
src/gen/messages/../../byte_ptr.h src/gen/messages/variant.h \
68+
src/gen/messages/classes.h src/gen/messages/../../bytes.h \
69+
src/gen/messages/../../message.h \
70+
src/gen/messages/../../gen/messages/variant.h \
71+
src/gen/messages/../../loc.h src/gen/messages/../../input.h \
72+
src/gen/messages/../../diagnostic.h
73+
74+
target/debug/gen/messages/render.o: src/gen/messages/render.cpp \
75+
src/gen/messages/render.h src/gen/messages/../../error_level.h \
76+
src/gen/messages/../../byte_ptr.h src/gen/messages/../../diagnostic.h \
77+
src/gen/messages/../../bytes.h src/gen/messages/../../loc.h \
78+
src/gen/messages/../../input.h src/gen/messages/../../message.h \
79+
src/gen/messages/../../gen/messages/variant.h \
80+
src/gen/messages/classes.h
81+
6182
target/debug/gen/nodes/classes.o: src/gen/nodes/classes.cpp \
6283
src/gen/nodes/classes.h src/gen/nodes/../../loc.h \
6384
src/gen/nodes/../../bytes.h src/gen/nodes/../../byte_ptr.h \

lib-ruby-parser-cpp-bindings/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ generate-bindings = ["bindgen", "lib-ruby-parser-nodes"]
1616
onig = ["lib-ruby-parser/onig"]
1717

1818
[dependencies]
19-
lib-ruby-parser = "=3.0.0-7"
19+
lib-ruby-parser = "=3.0.0-8"
2020

2121
[build-dependencies]
2222
bindgen = {version = "0.53.1", optional = true}
23-
lib-ruby-parser-nodes = {version = "0.11.0", optional = true}
23+
lib-ruby-parser-nodes = {version = "0.13.0", optional = true}

lib-ruby-parser-cpp-bindings/src/bindings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,9 @@ extern "C" {
10901090
pub fn make_encoding_error(level: ErrorLevel, loc: *mut Loc, error: BytePtr)
10911091
-> *mut Diagnostic;
10921092
}
1093+
extern "C" {
1094+
pub fn make_invalid_multibyte_char(level: ErrorLevel, loc: *mut Loc) -> *mut Diagnostic;
1095+
}
10931096
extern "C" {
10941097
pub fn make_ambiguous_ternary_operator(
10951098
level: ErrorLevel,

lib-ruby-parser-cpp-bindings/src/gen/messages.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ impl From<lib_ruby_parser::Diagnostic> for Ptr<bindings::Diagnostic> {
138138
let error = BytePtr::from(error);
139139
unsafe { bindings::make_encoding_error(level, loc, error) }
140140
},
141+
lib_ruby_parser::DiagnosticMessage::InvalidMultibyteChar { } => {
142+
unsafe { bindings::make_invalid_multibyte_char(level, loc, ) }
143+
},
141144
lib_ruby_parser::DiagnosticMessage::AmbiguousTernaryOperator { condition } => {
142145
let condition = BytePtr::from(condition);
143146
unsafe { bindings::make_ambiguous_ternary_operator(level, loc, condition) }

lib-ruby-parser-cpp-bindings/src/gen/render_message.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,18 @@ pub extern "C" fn render_message_encoding_error(level: bindings::ErrorLevel, loc
471471
BytePtr::from(message)
472472
}
473473

474+
#[no_mangle]
475+
pub extern "C" fn render_message_invalid_multibyte_char(level: bindings::ErrorLevel, loc: *mut bindings::Loc) -> BytePtr {
476+
let level = lib_ruby_parser::ErrorLevel::from(level);
477+
let loc = lib_ruby_parser::Loc::from(Ptr::new(loc));
478+
479+
let message = lib_ruby_parser::DiagnosticMessage::InvalidMultibyteChar { };
480+
let diagnostic = lib_ruby_parser::Diagnostic::new(level, message, loc);
481+
482+
let message = diagnostic.render_message();
483+
BytePtr::from(message)
484+
}
485+
474486
#[no_mangle]
475487
pub extern "C" fn render_message_ambiguous_ternary_operator(level: bindings::ErrorLevel, loc: *mut bindings::Loc, condition: BytePtr) -> BytePtr {
476488
let level = lib_ruby_parser::ErrorLevel::from(level);
@@ -1532,6 +1544,19 @@ pub extern "C" fn render_encoding_error(level: bindings::ErrorLevel, loc: *mut b
15321544
BytePtr::from(rendered)
15331545
}
15341546

1547+
#[no_mangle]
1548+
pub extern "C" fn render_invalid_multibyte_char(level: bindings::ErrorLevel, loc: *mut bindings::Loc, input: BytePtr) -> BytePtr {
1549+
let level = lib_ruby_parser::ErrorLevel::from(level);
1550+
let loc = lib_ruby_parser::Loc::from(Ptr::new(loc));
1551+
let input = lib_ruby_parser::source::Input::from(input);
1552+
1553+
let message = lib_ruby_parser::DiagnosticMessage::InvalidMultibyteChar { };
1554+
let diagnostic = lib_ruby_parser::Diagnostic::new(level, message, loc);
1555+
1556+
let rendered = diagnostic.render(&input);
1557+
BytePtr::from(rendered)
1558+
}
1559+
15351560
#[no_mangle]
15361561
pub extern "C" fn render_ambiguous_ternary_operator(level: bindings::ErrorLevel, loc: *mut bindings::Loc, condition: BytePtr, input: BytePtr) -> BytePtr {
15371562
let level = lib_ruby_parser::ErrorLevel::from(level);

src/gen/messages/classes.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ UnterminatedUnicodeEscape::UnterminatedUnicodeEscape()
159159
EncodingError::EncodingError(std::string error)
160160
{
161161
this->error = error;
162+
}
163+
InvalidMultibyteChar::InvalidMultibyteChar()
164+
{
165+
162166
}
163167
AmbiguousTernaryOperator::AmbiguousTernaryOperator(std::string condition)
164168
{
@@ -501,6 +505,10 @@ bool EncodingError::operator==(const EncodingError &other)
501505
{
502506
return error == other.error;
503507
}
508+
bool InvalidMultibyteChar::operator==(const InvalidMultibyteChar &)
509+
{
510+
return true;
511+
}
504512
bool AmbiguousTernaryOperator::operator==(const AmbiguousTernaryOperator &other)
505513
{
506514
return condition == other.condition;

src/gen/messages/classes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ class EncodingError: public BaseDiagnosticMessage {
250250
explicit EncodingError(std::string error);
251251
bool operator==(const EncodingError &other);
252252
};
253+
class InvalidMultibyteChar: public BaseDiagnosticMessage {
254+
public:
255+
256+
explicit InvalidMultibyteChar();
257+
bool operator==(const InvalidMultibyteChar &other);
258+
};
253259
class AmbiguousTernaryOperator: public BaseDiagnosticMessage {
254260
public:
255261
std::string condition;

src/gen/messages/make.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ Diagnostic *make_encoding_error(ErrorLevel level, Loc *loc, BytePtr error)
279279
std::make_unique<DiagnosticMessage>(std::make_unique<EncodingError>(byte_ptr_to_owned_string(error))),
280280
std::unique_ptr<Loc>(loc));
281281
}
282+
Diagnostic *make_invalid_multibyte_char(ErrorLevel level, Loc *loc)
283+
{
284+
return new Diagnostic(
285+
level,
286+
std::make_unique<DiagnosticMessage>(std::make_unique<InvalidMultibyteChar>()),
287+
std::unique_ptr<Loc>(loc));
288+
}
282289
Diagnostic *make_ambiguous_ternary_operator(ErrorLevel level, Loc *loc, BytePtr condition)
283290
{
284291
return new Diagnostic(

src/gen/messages/make.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Diagnostic *make_invalid_cvar_name(ErrorLevel level, Loc *loc, char c);
5050
Diagnostic *make_unknown_regex_options(ErrorLevel level, Loc *loc, BytePtr options);
5151
Diagnostic *make_unterminated_unicode_escape(ErrorLevel level, Loc *loc);
5252
Diagnostic *make_encoding_error(ErrorLevel level, Loc *loc, BytePtr error);
53+
Diagnostic *make_invalid_multibyte_char(ErrorLevel level, Loc *loc);
5354
Diagnostic *make_ambiguous_ternary_operator(ErrorLevel level, Loc *loc, BytePtr condition);
5455
Diagnostic *make_ambiguous_regexp(ErrorLevel level, Loc *loc);
5556
Diagnostic *make_else_without_rescue(ErrorLevel level, Loc *loc);

src/gen/messages/render.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ BytePtr render_message_diagnostic(Diagnostic *diagnostic)
128128
if constexpr (std::is_same_v<MessageT, std::unique_ptr<EncodingError>>) {
129129
return render_message_encoding_error(diagnostic->level, diagnostic->loc.get(), make_byte_ptr(message->error.c_str(), message->error.length()));
130130
}
131+
if constexpr (std::is_same_v<MessageT, std::unique_ptr<InvalidMultibyteChar>>) {
132+
return render_message_invalid_multibyte_char(diagnostic->level, diagnostic->loc.get());
133+
}
131134
if constexpr (std::is_same_v<MessageT, std::unique_ptr<AmbiguousTernaryOperator>>) {
132135
return render_message_ambiguous_ternary_operator(diagnostic->level, diagnostic->loc.get(), make_byte_ptr(message->condition.c_str(), message->condition.length()));
133136
}
@@ -391,6 +394,9 @@ BytePtr render_diagnostic(Diagnostic *diagnostic, BytePtr input)
391394
if constexpr (std::is_same_v<MessageT, std::unique_ptr<EncodingError>>) {
392395
return render_encoding_error(diagnostic->level, diagnostic->loc.get(), make_byte_ptr(message->error.c_str(), message->error.length()), input);
393396
}
397+
if constexpr (std::is_same_v<MessageT, std::unique_ptr<InvalidMultibyteChar>>) {
398+
return render_invalid_multibyte_char(diagnostic->level, diagnostic->loc.get(), input);
399+
}
394400
if constexpr (std::is_same_v<MessageT, std::unique_ptr<AmbiguousTernaryOperator>>) {
395401
return render_ambiguous_ternary_operator(diagnostic->level, diagnostic->loc.get(), make_byte_ptr(message->condition.c_str(), message->condition.length()), input);
396402
}

0 commit comments

Comments
 (0)