[Ometa] Translation problem in OMeta/JS (was: timeout problem)
Rüdiger Plantiko
ruediger.plantiko at astrotexte.ch
Thu Mar 25 07:36:59 PDT 2010
Der OMeta friends,
I could bring the problem to the point (it has nothing to do with negation):
Go to the OMeta/JS workspace http://www.tinlizzie.org/ometa-js/.
Then define the following simple oMeta object:
ometa M {
test = 'x':x 'y':y -> x + y
}
Now try to match the string 'xy':
M.matchAll( 'xy', 'test' )
>>> You will get an endless loop !
The JS transcript shows that for some unknown reasons the "->" is
swallowed. The test rule is treated as if I had written
test = 'x':x 'y':y x+ y
Since the "rule" x always retrieves the character 'x', the expression x+
blows up the result array with 'x' characters and never takes an end.
Here is the generated transcript of the above rule:
"test":function(){
var $elf=this,_fromIdx=this.input.idx,x,y;
return
(function(){
x=this._applyWithArgs("exactly","x");
y=this._applyWithArgs("exactly","y");
this._many1((function(){return x}));
return this._apply("y")
}).call(this)}
The rule can easily be saved by enclosing the semantic action into braces
like so:
ometa M {
test = 'x':x 'y':y -> { x + y }
}
But I don't understand why the first way is not transcribed as I expected
(and probably all of you would expect).
Regards,
Rüdiger
~~~~~~~~~~~~~~~~~~~~~~~~
Dr. Rüdiger Plantiko
Bachwiesenstrasse 28
CH-8405 Winterthur-Seen
http://ruediger-plantiko.net
More information about the OMeta
mailing list