Closed Jimw338 closed 5 years ago
Looks like you did everything right, but got bit by a poorly documented side effect of my technique for making the language case insensitive.
In your grammar, you have a lexer rule that matches a camel-case string:
| 'addThree' expression ',' expression ',' expression ',' expression
Unfortunately, in order to support case insensitive parsing, I use a special input stream that works only if all the tokens in the language are specified in lowercase. See: com.defano.wyldcard.runtime.interpreter.CaseInsensitiveInputStream
.
Here's what I think is happening: When you execute addThree a, b, c, d
in your mouseUp
handler, addThree
is not not matching your Antlr rule because of the way CaseInsensitiveInputStream
works. Instead, that statement is being interpreted as a HyperTalk message with four arguments, equivalent to saying send "addThree a, b, c, d"
. I bet if you added an on addThree
handler to your script, you'd see it fire.
Bottom line: Change your grammar rule to look like this and try it again:
| 'addthree' expression ',' expression ',' expression ',' expression
That worked!
I tried adding an "AddThree" command which is like add, but takes 4 parameters (3 "expressions" and 1 "container"). I modified the grammar (in both the the "commandStmnt" and "commandName" classes), the HyperTalkTreeVisitor file, and added a AddThreeCmd.java file. Right now just copies the function of add, but ignores the second and third parameters.
The grammar addition is:
The addition to HyperTalkTreeVisitor is:
It doesn't work, but doesn't complain that it's wrong either. The syntax coloring also doesn't work. It acts like it just skips over the line. The test script I have:
Is there something in the generated grammar or another "list of commands" that would cause it to be skipped in both the SyntaxParser to "ignore" the statement entirely?
Attached is my zip file of the project (I really need to look how to make commits).
wyldcard-master-unworking-addThreeCmd.zip