Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0.0 #9

Merged
merged 2 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions addons/clyde/parser/Lexer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion addons/clyde/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
21 changes: 17 additions & 4 deletions test/test_lexer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down