Skip to content

Commit

Permalink
Merge pull request #97 from Dinh-Hung-Tu/#86
Browse files Browse the repository at this point in the history
Fix #86 and allow continue ^ in triggers
  • Loading branch information
kirsle committed Jun 20, 2017
2 parents a2d0137 + 3d13551 commit 9fc7ed3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions rivescript/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def parse(self, filename, code):
continue
lookCmd = lookahead[0]
lookahead = lookahead[1:].strip()
lookahead = re.sub(RE.space, ' ', lookahead) # Replace the `\s` in the message

# Only continue if the lookahead line has any data.
if len(lookahead) != 0:
Expand Down
1 change: 1 addition & 0 deletions rivescript/regexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
class RE(object):
equals = re.compile('\s*=\s*')
ws = re.compile('\s+')
space = re.compile('\\\\s')
objend = re.compile('^\s*<\s*object')
weight = re.compile(r'\s*\{weight=(\d+)\}\s*')
inherit = re.compile('\{inherits=(\d+)\}')
Expand Down
21 changes: 21 additions & 0 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ def test_concat(self):
- Hello
^ world!
! local concat = none
+ test concat
^ in trigger
- Hello
^ world!
! local concat = none
+ [test] concat
^ \sin trigger with space and optional
- Hello
^ \sworld!
! local concat = space
+ test concat space
^ in trigger
- Hello
^ world!
// the option is file scoped so it can be left at
// any setting and won't affect subsequent parses
! local concat = newline
Expand All @@ -53,3 +71,6 @@ def test_concat(self):
self.reply("test concat none", "Helloworld!")
self.reply("test concat newline", "Hello\nworld!")
self.reply("test concat second file", "Helloworld!")
self.reply("test concatin trigger", "Helloworld!")
self.reply("test concat in trigger with space and optional", "Hello world!")
self.reply("test concat space in trigger", "Hello world!")

0 comments on commit 9fc7ed3

Please sign in to comment.