Skip to content

Commit

Permalink
v2.0.0 (#9)
Browse files Browse the repository at this point in the history
* add extra single-quote tests and remove unecessary check

* v2.0.0
  • Loading branch information
viniciusgerevini authored Oct 21, 2021
1 parent c47c188 commit dc8eed7
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
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

0 comments on commit dc8eed7

Please sign in to comment.