potential scoping bug in Parser.infix function
Closed this issue · 2 comments
Eclipse is reporting that this.first, this.second and this.bpow do not exist. Running the code 'as is' just crashes flash.
Updating the function within a function to the below seems to work, but perhaps I've killed something?:
function leftDenotation(lhs:Object):Object {
var obj:Object = {};
obj.first = lhs;
obj.second = expression(bpow);
return obj;
}
I'm surprised that works -- I tried it under Flash CS6 (publishing to Flash 11.2) and the parser SyntaxErrored on simple statements like 1 + 1. I don't have Eclipse, but I'd suggest this instead:
function leftDenotation(lhs:Object):Object {
var obj:Object = {};
obj.first = lhs;
obj.second = expression(bpow);
obj.codegen = infix_codegen(opcode);
obj.bpow = bpow;
return obj;
}
...because if you return an object without a bpow, all the infix operators will have an undefined operator precedence and 1 + 2 * 3 will be interpreted as (1 + 2) * 3, etc.
Which version of Flash Builder are you using, and which version of Flash are you publishing for?
I was getting Error: invalid expression statement :1+1;
Afraid with that update I'm getting the same error:
Error: invalid expression statement :1+1;
at org.sixsided.scripting.SJS::Parser/statement()[C:\Users\Andy\FBSeptFolder\JS\src\org\sixsided\scripting\SJS\Parser.as:483]
at org.sixsided.scripting.SJS::Parser/statements()[C:\Users\Andy\FBSeptFolder\JS\src\org\sixsided\scripting\SJS\Parser.as:494]
at org.sixsided.scripting.SJS::Parser/parse()[C:\Users\Andy\FBSeptFolder\JS\src\org\sixsided\scripting\SJS\Parser.as:99]
at org.sixsided.scripting.SJS::Interpreter/load()[C:\Users\Andy\FBSeptFolder\JS\src\org\sixsided\scripting\SJS\Interpreter.as:30]
at Main()[C:\Users\Andy\FBSeptFolder\JS\src\Main.as:20]
at JS()[C:\Users\Andy\FBSeptFolder\JS\src\JS.as:10]
I'm using FlashBuilder 4.7 with the very latest version of Flash.
Just replied to your tweet btw (dm not working?)