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

Actions overriding existing rules #46

Open
madeso opened this issue Mar 10, 2019 · 3 comments
Open

Actions overriding existing rules #46

madeso opened this issue Mar 10, 2019 · 3 comments

Comments

@madeso
Copy link

madeso commented Mar 10, 2019

From the syntax it looks like the actions are specific to the "rule call" and not globally set, but running this grammar in the online editor it looks to global.

{
"origin":"I love #[animal:#cat#]say# and #say#",
"say":"#animal.s#",
"animal": "dog",
"cat":"cat"
}

In the online editor this outputs: "I love cats and cats", and not what I would expect (I love cats and dogs).

To get the result that I want, the documentation suggests I need to use a POP before the second call, like this:

"origin":"I love #[animal:#cat#]say# and #[animal:POP]say#",

But this doesn't change anything, it still outputs "I love cats and cats".

What is the correct behavior here?

@galaxykate
Copy link
Owner

I don't remember how it behaves in this specific Tracery version, but the original intention was for push actions inside of the tags ie "#[animal:#cat#]say#" was to push a rule, and then autopop it once the tag finished expanding. Actions by themselves "[animal:#cat#] #say#" just push, but don't autopop.

Eventually though, I unofficially deprecated the autopop: no-one seemed to be using that functionality, and it made the book-keeping of push/pop more error-prone. For Tracery2, I'm leaving it out entirely. The syntax of putting [] inside ## conflicts with some of the new tracery2 features, but I think this is the only bit of tracery syntax that's been dropped/changed.

@galaxykate
Copy link
Owner

If you have a compelling use case for autopop, though, LMK! I don't want to take away features lightly.

@madeso
Copy link
Author

madeso commented Mar 11, 2019

There is no use case, except for me figuring out and writing unit tests for my implementation :)

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