superscriptjs / superscript

A dialogue engine for creating chat bots
http://superscriptjs.com
MIT License
1.65k stars 209 forks source link

[v1.0.0] require topic name in .ss #308

Closed hailiang-wang closed 7 years ago

hailiang-wang commented 7 years ago

Define a topic without a topic name.

image

Process it with ss-parser@v1.0.0 - alpha2.

Expected Behavior

save data.json.

Current Behavior

$ lib/bin/parse.js -f
undefined:3095
      throw peg$buildStructuredError(
      ^
SyntaxError: Expected " " or ":" but "\n" found.
    at peg$buildStructuredError (eval at compile (superscript/node_modules/pegjs/lib/compiler/index.js:67:37), <anonymous>:507:14)
    at Object.peg$parse [as parse] (eval at compile (/superscript/node_modules/pegjs/lib/compiler/index.js:67:37), <anonymous>:3095:13)
    at parseContents (superscript/node_modules/ss-parser/lib/parseContents.js:256:23)
    at /superscript/node_modules/ss-parser/lib/index.js:36:38
    at tryToString (fs.js:455:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)

Possible Solution

If define the topic as below, it works well.

image

The anonymous topic is defined as random topic, it should be supported in v1.0.0.

Your Environment

bensalilijames commented 7 years ago

On topics with no name: you can just put gambits/replies into the top-level script with no topics at all, and they’ll automatically be added into the random topic.

There’s no obligation to wrap everything in a topic, though of course, you can if you want, but they need a name (and if you really want to put gambits in the random topic within the topic syntax, you can just use the name random).