From 7da82ec4e64a9b59931dd1836e55a1c757a32218 Mon Sep 17 00:00:00 2001 From: Vinicius Gerevini Date: Thu, 21 Oct 2021 19:25:50 +1100 Subject: [PATCH 1/2] add extra single-quote tests and remove unecessary check --- addons/clyde/parser/Lexer.gd | 7 ++----- test/test_lexer.gd | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/addons/clyde/parser/Lexer.gd b/addons/clyde/parser/Lexer.gd index c2f563b..1f53a3e 100644 --- a/addons/clyde/parser/Lexer.gd +++ b/addons/clyde/parser/Lexer.gd @@ -519,12 +519,9 @@ func _handle_logic_block_stop(): func _handle_logic_block(): if _input[_position] == '"' or _input[_position] == "'": - if _current_quote: - if _input[_position] == _current_quote: - return _handle_logic_string() - else: + if not _current_quote: _current_quote = _input[_position] - return _handle_logic_string() + return _handle_logic_string() if _input[_position] == '}': return _handle_logic_block_stop() diff --git a/test/test_lexer.gd b/test/test_lexer.gd index a16382b..feaaf80 100644 --- a/test/test_lexer.gd +++ b/test/test_lexer.gd @@ -44,18 +44,31 @@ func test_text_with_quotes(): { "token": Lexer.TOKEN_EOF, "line": 0, "column": 53, "value": null }, ]) +func test_text_with_single_quotes(): + var lexer = Lexer.new() + var tokens = lexer.init("'this is a line with: special# characters $.\\' Enjoy'").get_all() + assert_eq_deep(tokens, [ + { + "token": Lexer.TOKEN_TEXT, + "value": "this is a line with: special# characters $.' Enjoy", + "line": 0, + "column": 1, + }, + { "token": Lexer.TOKEN_EOF, "line": 0, "column": 53, "value": null }, + ]) -func test_text_with_both_quote_types(): + +func test_text_with_both_leading_quote_types(): var lexer = Lexer.new() - var tokens = lexer.init("\"this is a 'line'\"").get_all() + var tokens = lexer.init("\"'this' is a 'line'\"").get_all() assert_eq_deep(tokens, [ { "token": Lexer.TOKEN_TEXT, - "value": "this is a 'line'", + "value": "'this' is a 'line'", "line": 0, "column": 1, }, - { "token": Lexer.TOKEN_EOF, "line": 0, "column": 18, "value": null }, + { "token": Lexer.TOKEN_EOF, "line": 0, "column": 20, "value": null }, ]) tokens = lexer.init('\'this is a "line"\'').get_all() assert_eq_deep(tokens, [ From 7a6ad06b1253a93e9684f20a18fc072171b872c7 Mon Sep 17 00:00:00 2001 From: Vinicius Gerevini Date: Thu, 21 Oct 2021 19:30:25 +1100 Subject: [PATCH 2/2] v2.0.0 --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ addons/clyde/plugin.cfg | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfb68c5..0dce16c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,37 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) +## 2.0.0 (2021-10-21) + +### Breaking Changes + +Dialogues starting with single quotes will escape especial characters. + +For example: +``` +'This is a #quoted text' +``` +Would previously return: +``` +TEXT: 'this is a +TAG: quoted +TEXT: text' +``` +Now it returns: +``` +TEXT: This is a #quoted text +``` + +### Changed + +- support single quotes for logic block string literals and escaping dialogues. + - `{ set string_literal = 'valid string' }` + - `'This is a valid escaped dialogue line # $ '` + +### Thanks + +Thanks to @verillious for suggesting and implementing these changes. + ## 1.0.2 (2021-06-04) ### Added diff --git a/addons/clyde/plugin.cfg b/addons/clyde/plugin.cfg index 15a6bcb..da98875 100644 --- a/addons/clyde/plugin.cfg +++ b/addons/clyde/plugin.cfg @@ -3,5 +3,5 @@ name="Clyde Dialogue" description="Interpreter and importer for Clyde Dialogue Language" author="Vinicius Gerevini" -version="1.0.2" +version="2.0.0" script="plugin.gd"