aichaos / rivescript-js

A RiveScript interpreter for JavaScript. RiveScript is a scripting language for chatterbots.
https://www.rivescript.com/
MIT License
377 stars 144 forks source link

`loadFile` and `loadDirectory` report syntax errors when there is a `^ Continuation` after a `* conditional` #314

Open elisehein opened 5 years ago

elisehein commented 5 years ago

I'm under the impression that this is valid syntax:

+ Hello
* <get variable> == 1 =>
^ Value is 1
- Value is not 1

However, loadFile and loadDirectory both report an error in this case:

Syntax error: Invalid format for !Condition: should be like '* value symbol value => response' at hello.rive line 2 near * <get variable> == 1 =>

I'm able to run the script after loading even though it logs an error.

The error doesn't appear if I put the conditional all on one line, or if I end the * Conditional line with a \s.

dcsan commented 5 years ago

theoretically it maybe legal but maybe the parser is just getting confused by the empty stuff before the linebreak.

* <get variable> == 1 => Value is 1

should work?

elisehein commented 5 years ago

@dcsan that does work fine. I have rather long lines in my scripts though and I'd much prefer splitting lines after the => for readability.

dcsan commented 5 years ago

maybe you can put some text on the same line... and just use ^ for the continuation.