-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Grammars in Twine #140
Comments
I think this it is possible to have something like this |
ok, can you include (either here or in a notebook) the simplest possible code for a <<rg>> macro as below:
and also with an optional start rule:
where rules is either a literal JS object, or a previously declared twine variable note: the only added benefit of doing this, over what what he have now, is that we can pass State.variables to grammar.expand automatically |
https://observablehq.com/@real-john-cheung/riscript-and-rigrammar-in-twine
|
the grammar() function already accepts json and js objects, no? why parse them separately ? |
because what inside Macro.playload.contents is string, so it need to be parsed into object grammar() actually can take in JSON string but literal jsobject string need to parsed first |
so we don't need JSON.parse in there, correct? |
We don't need it (i.e. we can code another (I think will be more complex) version that do the same without it) but maybe we should keep the JSON.parse() because we don't want to pass a random(unchecked) string into grammar(), and with it we can make sure that the type of the parameter pass in grammar() is always object. |
sounds good, reassigning to myself |
I'd like to support the following two types of grammar cases (with and without closing tag). Can you see if this is possible?
<<rg $rules >>
The text was updated successfully, but these errors were encountered: