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

trying to parse Harlowe text adventure language #372

Open
jnicho02 opened this issue Apr 21, 2018 · 3 comments
Open

trying to parse Harlowe text adventure language #372

jnicho02 opened this issue Apr 21, 2018 · 3 comments

Comments

@jnicho02
Copy link

Hi,

i'm working on a parser for the Harlowe language which is used in Twine text adventures. Rules are coming on fairly well, but my overall structure is lacking. Could anyone get me to the next step please?

https://github.com/jnicho02/nearley-harlowe

@tjvr
Copy link
Collaborator

tjvr commented Apr 23, 2018

Can you be more specific? I'm afraid we don't have the time to write a grammar for you! 😊

@jnicho02
Copy link
Author

jnicho02 commented Apr 23, 2018

I thought that might be the case :) ...pls believe me when I say i'm not just a noob asking you to do my homework. Just some first steps at structure that I can build on. My grammar so far is https://github.com/jnicho02/nearley-harlowe/blob/master/harlowe.ne

A Twine text adventure is written in a wiki-like language (perhaps you know of a good example grammar for Wiki that you could point me at?) with extended language that represents variables etc., e.g.

"You have started (set: $status to "started") in a dark room you can [[go north|north]] or [[go south|south]]"

So, I have defined rules to match narrative "You have started", code (set: $status...) and link [[go north...

What is the simplest way to specify that narrative, code, and links can appear in any combination, zero-or-many times?

@tjvr
Copy link
Collaborator

tjvr commented Apr 23, 2018

Something like this perhaps?

A rule is one or more things; a thing is either a narrative, code, or a link.

rule -> rule thing {% ([xl, x]) => xl.concat([x]) %}
      | thing {% id %}

thing -> narrative {% id %} | code {% id %} | link {% id %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants