Kappa-Dev / KappaTools

Tool suite for kappa models. Documentation and binaries can be found in the release section. Try it online at
http://kappalanguage.org/
GNU Lesser General Public License v3.0
110 stars 40 forks source link

Mods with Tokens #607

Closed rkruegs123 closed 4 years ago

rkruegs123 commented 4 years ago

I haven't been able to get perturbations to work with tokens. In the simple case, I am trying to add some number X of token Tok at time T. From the manual, this should be as simple as:

%mod: alarm T do Tok <- X;

Any thoughts?

rkruegs123 commented 4 years ago

93 led me to

%mod: [T]=10 do $APPLY -> | 100 a

which did not work for me, but

%mod: [T]=10 do $APPLY 1 . -> . | 100 a;

did. However, I still do not totally understand the logic behind the syntax.

pirbo commented 4 years ago

Hi,

TL;DR; Tok <- X; (aka set the value of Tok to X) has always been internally but has now to be explicitely phrased as $APPLY 1 | X - |Tok| Tok; (aka apply once the rule that increments the value of Tok of X minus former value of Tok) and the manual has to be updated.

Longer story: Interventions $ADD, $DELETE and the former <- are all special cases of "apply a rule k time". The generalized form is now available as you noticed as $APPLY [nb_app] [rule_expr]. Syntactic sugar has been kept of the 2 first form because there were no drawback but the last causes "shift-reduce conflicts" in the parser so it has been dropped (and the manual must be updated accordingly! sorry again)

%mod: [T]=10 do $APPLY -> | 100 a is wrong because it lacks how many time the rule has to be applied (which is a bit weird in the case of rules involving only tokens I agree but again I have troubles allowing the 1 being implicit while keeping the grammar of the language unambiguous). (It also lacks the semi-colon).

pirbo commented 4 years ago

Manual updated so I'll close this but reopen an issue if there is still something unsatisfactory