From 67ce9e28a5f8d800176dd2749f884be8f7f64de2 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Mon, 24 Jan 2022 23:47:22 +0200 Subject: AK: Standardize the behaviour of GenericLexer::consume_until overloads Before this commit all consume_until overloads aside from the Predicate one would consume (and ignore) the stop char/string, while the Predicate overload would not, in order to keep behaviour consistent, the other overloads no longer consume the stop char/string as well. --- Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp | 5 ++++- Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'Meta/Lagom') diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp index 6c4b86c941..b77794afcd 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp @@ -230,6 +230,7 @@ static NonnullOwnPtr parse_interface(StringView filename, StringView if (lexer.consume_specific("//")) { lexer.consume_until('\n'); + lexer.ignore(); consumed = true; } } @@ -276,7 +277,9 @@ static NonnullOwnPtr parse_interface(StringView filename, StringView while (lexer.consume_specific("#import")) { consume_whitespace(); assert_specific('<'); - imports.append(resolve_import(lexer.consume_until('>'))); + auto path = lexer.consume_until('>'); + lexer.ignore(); + imports.append(resolve_import(path)); consume_whitespace(); } diff --git a/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp b/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp index 4e3a903990..2c506fbb36 100644 --- a/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp @@ -88,10 +88,12 @@ parse_state_machine(StringView input) num = 16 * num + get_hex_value(c); } else { lexer.consume_specific('\''); - if (lexer.next_is('\\')) + if (lexer.next_is('\\')) { num = (int)lexer.consume_escaped_character('\\'); - else + } else { num = lexer.consume_until('\'').to_int().value(); + lexer.ignore(); + } lexer.consume_specific('\''); } return num; -- cgit v1.2.3