Parsing text...again

Dear all,

I have a switch that you can set to left, middle or right. Works fine like this:

before [;




Now I want to allow “switch switch to left|middle|right” as well without removing the normal switch function. So I extend the grammar:

Extend only ‘switch’ first * noun ‘to’ topic → Verb_MySwitch;

According to the parser output in “actions” mode it seems to me that no “second” argument is passed to my Verb_MySwitchSub routine:

switch switch to right
[ Action Verb_MySwitch with noun 245 (switch) ]

Question 1: What do I need to do to be able to parse for left|middle|right in my Verb_MySwitchSub routine?
Question 2: Since I do have the desired code in the switch object, I’d intuitively just use <> in the Verb_MySwitchSub routine, but how do I pass on the left|middle|right text?


If you look at Grammar.h, you’ll see that set is defined this way:

Verb 'set' 'adjust'
    * noun                                      -> Set
    * noun 'to' special                         -> SetTo;

So this works:

[ Verb_MySwitchSub;
	<<SetTo switch second>>;

Extend only 'switch' first * noun 'to' special -> Verb_MySwitch;
1 Like

I’m thinking that "flip switch " or “set switch to” is preferable to “switch switch”, but it sure is nice that inform allows to do so easily.

It works! Thanks Zarf!!!

Alternatively, you might be able to use:

Extend only 'switch' first
  * noun 'to' special -> SetTo;

I think this does the same as Zarf’s solution, but it doesn’t need the redundant Verb_MySwitch action.