Program: 61884
Project: 61884
Buggy source:
private GraphTargetItem command(HashMap<String,Integer> registerVars,boolean inFunction,boolean inMethod,int forinlevel,boolean mustBeCommand,List<VariableActionItem> variables) throws IOException, ParseException {
  LexBufferer buf=new LexBufferer();
  lexer.addListener(buf);
  GraphTargetItem ret=null;
  if (debugMode) {
    System.out.println("String_Node_Str");
  }
  ParsedSymbol s=lex();
  if (s.type == SymbolType.EOF) {
    return null;
  }
switch (s.type) {
case CALL:
    expectedType(SymbolType.PARENT_OPEN);
  ret=new CallActionItem(null,(expression(registerVars,inFunction,inMethod,true,variables)));
expectedType(SymbolType.PARENT_CLOSE);
break;
case LENGTH:
expectedType(SymbolType.PARENT_OPEN);
ret=new StringLengthActionItem(null,(expression(registerVars,inFunction,inMethod,true,variables)));
expectedType(SymbolType.PARENT_CLOSE);
break;
case MBLENGTH:
expectedType(SymbolType.PARENT_OPEN);
ret=new MBStringLengthActionItem(null,(expression(registerVars,inFunction,inMethod,true,variables)));
expectedType(SymbolType.PARENT_CLOSE);
break;
case SET:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem name1=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.COMMA);
GraphTargetItem value1=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.PARENT_CLOSE);
ret=new SetVariableActionItem(null,name1,value1);
break;
case WITH:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem wvar=(variable(registerVars,inFunction,inMethod,variables));
expectedType(SymbolType.PARENT_CLOSE);
expectedType(SymbolType.CURLY_OPEN);
List<GraphTargetItem> wcmd=commands(registerVars,inFunction,inMethod,forinlevel,variables);
expectedType(SymbolType.CURLY_CLOSE);
ret=new WithActionItem(null,wvar,wcmd);
break;
case DELETE:
GraphTargetItem varDel=variable(registerVars,inFunction,inMethod,variables);
if (varDel instanceof GetMemberActionItem) {
GetMemberActionItem gm=(GetMemberActionItem)varDel;
ret=new DeleteActionItem(null,gm.object,gm.memberName);
}
 else {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case TRACE:
expectedType(SymbolType.PARENT_OPEN);
ret=new TraceActionItem(null,(expression(registerVars,inFunction,inMethod,true,variables)));
expectedType(SymbolType.PARENT_CLOSE);
break;
case GETURL:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem url=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
expected(s,lexer.yyline(),SymbolType.PARENT_CLOSE,SymbolType.COMMA);
int getuMethod=1;
GraphTargetItem target=null;
if (s.type == SymbolType.COMMA) {
target=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
if (s.type == SymbolType.COMMA) {
s=lex();
expected(s,lexer.yyline(),SymbolType.STRING);
if (s.value.equals("String_Node_Str")) {
getuMethod=1;
}
 else if (s.value.equals("String_Node_Str")) {
getuMethod=2;
}
 else {
throw new ParseException("String_Node_Str",lexer.yyline());
}
}
 else {
lexer.pushback(s);
}
}
 else {
lexer.pushback(s);
target=new DirectValueActionItem(null,0,"String_Node_Str",new ArrayList<String>());
}
expectedType(SymbolType.PARENT_CLOSE);
ret=new GetURL2ActionItem(null,url,target,getuMethod);
break;
case GOTOANDSTOP:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem gtsFrame=expression(registerVars,inFunction,inMethod,true,variables);
s=lex();
if (s.type == SymbolType.COMMA) {
s=lex();
gtsFrame=expression(registerVars,inFunction,inMethod,true,variables);
}
 else {
lexer.pushback(s);
}
ret=new GotoFrame2ActionItem(null,gtsFrame,false,false,0);
expectedType(SymbolType.PARENT_CLOSE);
break;
case NEXTFRAME:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new NextFrameActionItem(null);
break;
case PLAY:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new PlayActionItem(null);
break;
case PREVFRAME:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new PrevFrameActionItem(null);
break;
case TELLTARGET:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem tellTarget=expression(registerVars,inFunction,inMethod,true,variables);
expectedType(SymbolType.PARENT_CLOSE);
expectedType(SymbolType.CURLY_OPEN);
List<GraphTargetItem> tellcmds=commands(registerVars,inFunction,inMethod,forinlevel,variables);
expectedType(SymbolType.CURLY_CLOSE);
ret=new TellTargetActionItem(null,tellTarget,tellcmds);
break;
case STOP:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new StopActionItem(null);
break;
case STOPALLSOUNDS:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new StopAllSoundsActionItem(null);
break;
case TOGGLEHIGHQUALITY:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new ToggleHighQualityActionItem(null);
break;
case STOPDRAG:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new StopDragActionItem(null);
break;
case UNLOADMOVIE:
case UNLOADMOVIENUM:
SymbolType unloadType=s.type;
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem unTargetOrNum=expression(registerVars,inFunction,inMethod,true,variables);
expectedType(SymbolType.PARENT_CLOSE);
if (unloadType == SymbolType.UNLOADMOVIE) {
ret=new UnLoadMovieActionItem(null,unTargetOrNum);
}
if (unloadType == SymbolType.UNLOADMOVIENUM) {
ret=new UnLoadMovieNumActionItem(null,unTargetOrNum);
}
break;
case PRINT:
case PRINTASBITMAP:
case PRINTASBITMAPNUM:
case PRINTNUM:
SymbolType printType=s.type;
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem printTarget=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.COMMA);
GraphTargetItem printBBox=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.PARENT_CLOSE);
switch (printType) {
case PRINT:
ret=new PrintActionItem(null,printTarget,printBBox);
break;
case PRINTNUM:
ret=new PrintNumActionItem(null,printTarget,printBBox);
break;
case PRINTASBITMAP:
ret=new PrintAsBitmapActionItem(null,printTarget,printBBox);
break;
case PRINTASBITMAPNUM:
ret=new PrintAsBitmapNumActionItem(null,printTarget,printBBox);
break;
}
break;
case LOADVARIABLES:
case LOADMOVIE:
case LOADVARIABLESNUM:
case LOADMOVIENUM:
SymbolType loadType=s.type;
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem url2=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.COMMA);
GraphTargetItem targetOrNum=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
expected(s,lexer.yyline(),SymbolType.PARENT_CLOSE,SymbolType.COMMA);
int lvmethod=1;
if (s.type == SymbolType.COMMA) {
s=lex();
expected(s,lexer.yyline(),SymbolType.STRING);
if (s.value.equals("String_Node_Str")) {
lvmethod=2;
}
 else if (s.value.equals("String_Node_Str")) {
lvmethod=1;
}
 else {
throw new ParseException("String_Node_Str",lexer.yyline());
}
}
 else {
lexer.pushback(s);
}
expectedType(SymbolType.PARENT_CLOSE);
switch (loadType) {
case LOADVARIABLES:
ret=new LoadVariablesActionItem(null,url2,targetOrNum,lvmethod);
break;
case LOADMOVIE:
ret=new LoadMovieActionItem(null,url2,targetOrNum,lvmethod);
break;
case LOADVARIABLESNUM:
ret=new LoadVariablesNumActionItem(null,url2,targetOrNum,lvmethod);
break;
case LOADMOVIENUM:
ret=new LoadMovieNumActionItem(null,url2,targetOrNum,lvmethod);
break;
}
break;
case GOTOANDPLAY:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem gtpFrame=expression(registerVars,inFunction,inMethod,true,variables);
s=lex();
if (s.type == SymbolType.COMMA) {
s=lex();
gtpFrame=expression(registerVars,inFunction,inMethod,true,variables);
}
 else {
lexer.pushback(s);
}
ret=new GotoFrame2ActionItem(null,gtpFrame,true,false,0);
expectedType(SymbolType.PARENT_CLOSE);
break;
case REMOVEMOVIECLIP:
expectedType(SymbolType.PARENT_OPEN);
ret=new RemoveSpriteActionItem(null,(expression(registerVars,inFunction,inMethod,true,variables)));
expectedType(SymbolType.PARENT_CLOSE);
break;
case STARTDRAG:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem dragTarget=(expression(registerVars,inFunction,inMethod,true,variables));
GraphTargetItem lockCenter=null;
GraphTargetItem constrain=null;
GraphTargetItem x1=null;
GraphTargetItem y1=null;
GraphTargetItem x2=null;
GraphTargetItem y2=null;
s=lex();
if (s.type == SymbolType.COMMA) {
lockCenter=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
if (s.type == SymbolType.COMMA) {
constrain=new DirectValueActionItem(null,0,Boolean.TRUE,new ArrayList<String>());
x1=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
if (s.type == SymbolType.COMMA) {
y1=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
if (s.type == SymbolType.COMMA) {
x2=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
if (s.type == SymbolType.COMMA) {
y2=(expression(registerVars,inFunction,inMethod,true,variables));
}
 else {
lexer.pushback(s);
y2=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
}
}
 else {
lexer.pushback(s);
x2=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
y2=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
}
}
 else {
lexer.pushback(s);
x2=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
y2=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
y1=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
}
}
 else {
lexer.pushback(s);
constrain=new DirectValueActionItem(null,0,Boolean.FALSE,new ArrayList<String>());
}
}
 else {
lockCenter=new DirectValueActionItem(null,0,Boolean.FALSE,new ArrayList<String>());
constrain=new DirectValueActionItem(null,0,Boolean.FALSE,new ArrayList<String>());
lexer.pushback(s);
}
expectedType(SymbolType.PARENT_CLOSE);
ret=new StartDragActionItem(null,dragTarget,lockCenter,constrain,x1,y1,x2,y2);
break;
case IFFRAMELOADED:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem iflExpr=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.PARENT_CLOSE);
expectedType(SymbolType.CURLY_OPEN);
List<GraphTargetItem> iflComs=commands(registerVars,inFunction,inMethod,forinlevel,variables);
expectedType(SymbolType.CURLY_CLOSE);
ret=new IfFrameLoadedActionItem(iflExpr,iflComs,null);
break;
case CLASS:
GraphTargetItem classTypeStr=type(variables);
s=lex();
GraphTargetItem extendsTypeStr=null;
if (s.type == SymbolType.EXTENDS) {
extendsTypeStr=type(variables);
s=lex();
}
List<GraphTargetItem> implementsTypeStrs=new ArrayList<>();
if (s.type == SymbolType.IMPLEMENTS) {
do {
GraphTargetItem implementsTypeStr=type(variables);
implementsTypeStrs.add(implementsTypeStr);
s=lex();
}
 while (s.type == SymbolType.COMMA);
}
expected(s,lexer.yyline(),SymbolType.CURLY_OPEN);
ret=(traits(false,classTypeStr,extendsTypeStr,implementsTypeStrs,variables));
expectedType(SymbolType.CURLY_CLOSE);
break;
case INTERFACE:
GraphTargetItem interfaceTypeStr=type(variables);
s=lex();
List<GraphTargetItem> intExtendsTypeStrs=new ArrayList<>();
if (s.type == SymbolType.EXTENDS) {
do {
GraphTargetItem intExtendsTypeStr=type(variables);
intExtendsTypeStrs.add(intExtendsTypeStr);
s=lex();
}
 while (s.type == SymbolType.COMMA);
}
expected(s,lexer.yyline(),SymbolType.CURLY_OPEN);
ret=(traits(true,interfaceTypeStr,null,intExtendsTypeStrs,variables));
expectedType(SymbolType.CURLY_CLOSE);
break;
case FUNCTION:
s=lexer.lex();
expected(s,lexer.yyline(),SymbolType.IDENTIFIER);
ret=(function(true,s.value.toString(),false,variables));
break;
case NEW:
GraphTargetItem type=type(variables);
expectedType(SymbolType.PARENT_OPEN);
if (type instanceof GetMemberActionItem) {
GetMemberActionItem mem=(GetMemberActionItem)type;
ret=new NewMethodActionItem(null,mem.object,mem.memberName,call(registerVars,inFunction,inMethod,variables));
}
 else if (type instanceof VariableActionItem) {
VariableActionItem var=(VariableActionItem)type;
ret=new NewObjectActionItem(null,var,call(registerVars,inFunction,inMethod,variables));
}
 else {
ret=new NewObjectActionItem(null,ret,call(registerVars,inFunction,inMethod,variables));
}
break;
case VAR:
s=lex();
expected(s,lexer.yyline(),SymbolType.IDENTIFIER);
String varIdentifier=s.value.toString();
s=lex();
if (s.type == SymbolType.COLON) {
type(variables);
s=lex();
}
if (s.type == SymbolType.ASSIGN) {
if (!inFunction) {
}
GraphTargetItem varval=(expression(registerVars,inFunction,inMethod,true,variables));
ret=new VariableActionItem(varIdentifier,varval,true);
variables.add((VariableActionItem)ret);
}
 else {
ret=new VariableActionItem(varIdentifier,null,true);
variables.add((VariableActionItem)ret);
lexer.pushback(s);
}
break;
case CURLY_OPEN:
ret=new BlockItem(null,commands(registerVars,inFunction,inMethod,forinlevel,variables));
expectedType(SymbolType.CURLY_CLOSE);
break;
case INCREMENT:
case DECREMENT:
GraphTargetItem varincdec=variable(registerVars,inFunction,inMethod,variables);
if (s.type == SymbolType.INCREMENT) {
ret=new PreIncrementActionItem(null,varincdec);
}
 else if (s.type == SymbolType.DECREMENT) {
ret=new PreDecrementActionItem(null,varincdec);
}
break;
case IDENTIFIER:
case THIS:
case SUPER:
case PARENT_OPEN:
case EVAL:
ParsedSymbol varS=s;
boolean isEval=false;
GraphTargetItem var;
if (s.type == SymbolType.PARENT_OPEN) {
var=expression(registerVars,inFunction,inMethod,true,variables);
expectedType(SymbolType.PARENT_CLOSE);
memberOrCall(var,registerVars,inFunction,inMethod,variables);
}
 else if (s.type == SymbolType.EVAL) {
expectedType(SymbolType.PARENT_OPEN);
var=expression(registerVars,inFunction,inMethod,true,variables);
var=new EvalActionItem(null,var);
expectedType(SymbolType.PARENT_CLOSE);
var=memberOrCall(var,registerVars,inFunction,inMethod,variables);
isEval=true;
}
 else {
lexer.pushback(s);
var=variable(registerVars,inFunction,inMethod,variables);
}
s=lex();
switch (s.type) {
case ASSIGN:
ret=var;
ret=Action.gettoset(ret,expression(registerVars,inFunction,inMethod,true,variables),variables);
break;
case ASSIGN_BITAND:
case ASSIGN_BITOR:
case ASSIGN_DIVIDE:
case ASSIGN_MINUS:
case ASSIGN_MODULO:
case ASSIGN_MULTIPLY:
case ASSIGN_PLUS:
case ASSIGN_SHIFT_LEFT:
case ASSIGN_SHIFT_RIGHT:
case ASSIGN_USHIFT_RIGHT:
case ASSIGN_XOR:
GraphTargetItem valtoappend=(expression(registerVars,inFunction,inMethod,true,variables));
switch (s.type) {
case ASSIGN_BITAND:
ret=Action.gettoset(var,new BitAndActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_BITOR:
ret=Action.gettoset(var,new BitOrActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_DIVIDE:
ret=Action.gettoset(var,new DivideActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_MINUS:
ret=Action.gettoset(var,new SubtractActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_MODULO:
ret=Action.gettoset(var,new ModuloActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_MULTIPLY:
ret=Action.gettoset(var,new MultiplyActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_PLUS:
ret=Action.gettoset(var,new AddActionItem(null,var,valtoappend,true),variables);
break;
}
break;
case INCREMENT:
ret=new PostIncrementActionItem(null,var);
break;
case DECREMENT:
ret=new PostDecrementActionItem(null,var);
break;
case PARENT_OPEN:
ret=var;
if (varS.type == SymbolType.SUPER || varS.type == SymbolType.THIS) {
List<GraphTargetItem> args=call(registerVars,inFunction,inMethod,variables);
ret=new CallMethodActionItem(null,ret,new DirectValueActionItem(null,0,new Undefined(),constantPool),args);
}
 else {
lexer.pushback(s);
ret=memberOrCall(ret,registerVars,inFunction,inMethod,variables);
}
break;
default :
if (isEval) {
ret=var;
}
 else {
if (mustBeCommand) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
}
}
break;
case IF:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem ifExpr=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.PARENT_CLOSE);
GraphTargetItem onTrue=command(registerVars,inFunction,inMethod,forinlevel,true,variables);
List<GraphTargetItem> onTrueList=new ArrayList<>();
onTrueList.add(onTrue);
s=lex();
List<GraphTargetItem> onFalseList=null;
if (s.type == SymbolType.ELSE) {
onFalseList=new ArrayList<>();
onFalseList.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
}
 else {
lexer.pushback(s);
}
ret=new IfItem(null,ifExpr,onTrueList,onFalseList);
break;
case WHILE:
expectedType(SymbolType.PARENT_OPEN);
List<GraphTargetItem> whileExpr=new ArrayList<>();
whileExpr.add(commaExpression(registerVars,inFunction,inMethod,forinlevel,variables));
expectedType(SymbolType.PARENT_CLOSE);
List<GraphTargetItem> whileBody=new ArrayList<>();
whileBody.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
ret=new WhileItem(null,null,whileExpr,whileBody);
break;
case DO:
List<GraphTargetItem> doBody=new ArrayList<>();
doBody.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
expectedType(SymbolType.WHILE);
expectedType(SymbolType.PARENT_OPEN);
List<GraphTargetItem> doExpr=new ArrayList<>();
doExpr.add(commaExpression(registerVars,inFunction,inMethod,forinlevel,variables));
expectedType(SymbolType.PARENT_CLOSE);
ret=new DoWhileItem(null,null,doBody,doExpr);
break;
case FOR:
expectedType(SymbolType.PARENT_OPEN);
s=lex();
boolean forin=false;
GraphTargetItem collection=null;
String objIdent=null;
int innerExprReg=0;
if (s.type == SymbolType.VAR || s.type == SymbolType.IDENTIFIER) {
ParsedSymbol s2=null;
ParsedSymbol ssel=s;
if (s.type == SymbolType.VAR) {
s2=lex();
ssel=s2;
}
if (ssel.type == SymbolType.IDENTIFIER) {
objIdent=ssel.value.toString();
ParsedSymbol s3=lex();
if (s3.type == SymbolType.IN) {
if (inFunction) {
for (int i=0; i < 256; i++) {
if (!registerVars.containsValue(i)) {
registerVars.put(objIdent,i);
innerExprReg=i;
break;
}
}
}
collection=expression(registerVars,inFunction,inMethod,true,variables);
forin=true;
}
 else {
lexer.pushback(s3);
if (s2 != null) {
lexer.pushback(s2);
}
lexer.pushback(s);
}
}
 else {
if (s2 != null) {
lexer.pushback(s2);
}
lexer.pushback(s);
}
}
 else {
lexer.pushback(s);
}
List<GraphTargetItem> forFinalCommands=new ArrayList<>();
GraphTargetItem forExpr=null;
List<GraphTargetItem> forFirstCommands=new ArrayList<>();
if (!forin) {
forFirstCommands.add((command(registerVars,inFunction,inMethod,forinlevel,true,variables)));
forExpr=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.SEMICOLON);
forFinalCommands.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
}
expectedType(SymbolType.PARENT_CLOSE);
List<GraphTargetItem> forBody=new ArrayList<>();
forBody.add(command(registerVars,inFunction,inMethod,forin ? forinlevel + 1 : forinlevel,true,variables));
if (forin) {
ret=new ForInActionItem(null,null,pushConst(objIdent),collection,forBody);
}
 else {
ret=new ForItem(null,null,forFirstCommands,forExpr,forFinalCommands,forBody);
}
break;
case SWITCH:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem switchExpr=expression(registerVars,inFunction,inMethod,true,variables);
expectedType(SymbolType.PARENT_CLOSE);
expectedType(SymbolType.CURLY_OPEN);
s=lex();
int exprReg=0;
for (int i=0; i < 256; i++) {
if (!registerVars.containsValue(i)) {
registerVars.put("String_Node_Str" + uniqId(),i);
exprReg=i;
break;
}
}
List<List<ActionIf>> caseIfs=new ArrayList<>();
List<List<GraphTargetItem>> caseCmds=new ArrayList<>();
List<GraphTargetItem> caseExprsAll=new ArrayList<>();
List<Integer> valueMapping=new ArrayList<>();
int pos=0;
while (s.type == SymbolType.CASE) {
List<GraphTargetItem> caseExprs=new ArrayList<>();
while (s.type == SymbolType.CASE) {
GraphTargetItem curCaseExpr=expression(registerVars,inFunction,inMethod,true,variables);
caseExprs.add(curCaseExpr);
expectedType(SymbolType.COLON);
s=lex();
caseExprsAll.add(curCaseExpr);
valueMapping.add(pos);
}
pos++;
lexer.pushback(s);
List<GraphTargetItem> caseCmd=commands(registerVars,inFunction,inMethod,forinlevel,variables);
caseCmds.add(caseCmd);
s=lex();
}
List<GraphTargetItem> defCmd=new ArrayList<>();
if (s.type == SymbolType.DEFAULT) {
expectedType(SymbolType.COLON);
defCmd=commands(registerVars,inFunction,inMethod,forinlevel,variables);
s=lexer.lex();
}
expected(s,lexer.yyline(),SymbolType.CURLY_CLOSE);
ret=new SwitchItem(null,null,switchExpr,caseExprsAll,caseCmds,defCmd,valueMapping);
break;
case BREAK:
ret=new BreakItem(null,0);
break;
case CONTINUE:
ret=new ContinueItem(null,0);
break;
case RETURN:
GraphTargetItem retexpr=expression(true,registerVars,inFunction,inMethod,true,variables);
if (retexpr == null) {
retexpr=new DirectValueActionItem(null,0,new Undefined(),new ArrayList<String>());
}
ret=new ReturnActionItem(null,retexpr);
break;
case TRY:
List<GraphTargetItem> tryCommands=new ArrayList<>();
tryCommands.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
s=lex();
boolean found=false;
List<List<GraphTargetItem>> catchCommands=null;
List<GraphTargetItem> catchExceptions=new ArrayList<>();
if (s.type == SymbolType.CATCH) {
expectedType(SymbolType.PARENT_OPEN);
s=lex();
expected(s,lexer.yyline(),SymbolType.IDENTIFIER,SymbolType.STRING);
catchExceptions.add(pushConst((String)s.value));
expectedType(SymbolType.PARENT_CLOSE);
catchCommands=new ArrayList<>();
List<GraphTargetItem> cc=new ArrayList<>();
cc.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
catchCommands.add(cc);
s=lex();
found=true;
}
List<GraphTargetItem> finallyCommands=null;
if (s.type == SymbolType.FINALLY) {
finallyCommands=new ArrayList<>();
finallyCommands.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
found=true;
s=lex();
}
if (!found) {
expected(s,lexer.yyline(),SymbolType.CATCH,SymbolType.FINALLY);
}
lexer.pushback(s);
ret=new TryActionItem(tryCommands,catchExceptions,catchCommands,finallyCommands);
break;
case THROW:
ret=new ThrowActionItem(null,expression(registerVars,inFunction,inMethod,true,variables));
break;
default :
GraphTargetItem valcmd=expressionCommands(s,registerVars,inFunction,inMethod,forinlevel,variables);
if (valcmd != null) {
ret=valcmd;
break;
}
if (s.type != SymbolType.SEMICOLON) {
lexer.pushback(s);
}
if (debugMode) {
System.out.println("String_Node_Str");
}
return null;
}
s=lex();
if ((s != null) && (s.type != SymbolType.SEMICOLON)) {
lexer.pushback(s);
}
if (debugMode) {
System.out.println("String_Node_Str");
}
if (ret == null && (!mustBeCommand)) {
buf.pushAllBack(lexer);
}
lexer.removeListener(buf);
return ret;
}

Fixed version (ground truth):
private GraphTargetItem command(HashMap<String,Integer> registerVars,boolean inFunction,boolean inMethod,int forinlevel,boolean mustBeCommand,List<VariableActionItem> variables) throws IOException, ParseException {
  LexBufferer buf=new LexBufferer();
  lexer.addListener(buf);
  GraphTargetItem ret=null;
  if (debugMode) {
    System.out.println("String_Node_Str");
  }
  ParsedSymbol s=lex();
  if (s.type == SymbolType.EOF) {
    return null;
  }
switch (s.type) {
case CALL:
    expectedType(SymbolType.PARENT_OPEN);
  ret=new CallActionItem(null,(expression(registerVars,inFunction,inMethod,true,variables)));
expectedType(SymbolType.PARENT_CLOSE);
break;
case LENGTH:
expectedType(SymbolType.PARENT_OPEN);
ret=new StringLengthActionItem(null,(expression(registerVars,inFunction,inMethod,true,variables)));
expectedType(SymbolType.PARENT_CLOSE);
break;
case MBLENGTH:
expectedType(SymbolType.PARENT_OPEN);
ret=new MBStringLengthActionItem(null,(expression(registerVars,inFunction,inMethod,true,variables)));
expectedType(SymbolType.PARENT_CLOSE);
break;
case SET:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem name1=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.COMMA);
GraphTargetItem value1=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.PARENT_CLOSE);
ret=new SetVariableActionItem(null,name1,value1);
break;
case WITH:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem wvar=(variable(registerVars,inFunction,inMethod,variables));
expectedType(SymbolType.PARENT_CLOSE);
expectedType(SymbolType.CURLY_OPEN);
List<GraphTargetItem> wcmd=commands(registerVars,inFunction,inMethod,forinlevel,variables);
expectedType(SymbolType.CURLY_CLOSE);
ret=new WithActionItem(null,wvar,wcmd);
break;
case DELETE:
GraphTargetItem varDel=variable(registerVars,inFunction,inMethod,variables);
if (varDel instanceof GetMemberActionItem) {
GetMemberActionItem gm=(GetMemberActionItem)varDel;
ret=new DeleteActionItem(null,gm.object,gm.memberName);
}
 else {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case TRACE:
expectedType(SymbolType.PARENT_OPEN);
ret=new TraceActionItem(null,(expression(registerVars,inFunction,inMethod,true,variables)));
expectedType(SymbolType.PARENT_CLOSE);
break;
case GETURL:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem url=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
expected(s,lexer.yyline(),SymbolType.PARENT_CLOSE,SymbolType.COMMA);
int getuMethod=1;
GraphTargetItem target=null;
if (s.type == SymbolType.COMMA) {
target=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
if (s.type == SymbolType.COMMA) {
s=lex();
expected(s,lexer.yyline(),SymbolType.STRING);
if (s.value.equals("String_Node_Str")) {
getuMethod=1;
}
 else if (s.value.equals("String_Node_Str")) {
getuMethod=2;
}
 else {
throw new ParseException("String_Node_Str",lexer.yyline());
}
}
 else {
lexer.pushback(s);
}
}
 else {
lexer.pushback(s);
target=new DirectValueActionItem(null,0,"String_Node_Str",new ArrayList<String>());
}
expectedType(SymbolType.PARENT_CLOSE);
ret=new GetURL2ActionItem(null,url,target,getuMethod);
break;
case GOTOANDSTOP:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem gtsFrame=expression(registerVars,inFunction,inMethod,true,variables);
s=lex();
if (s.type == SymbolType.COMMA) {
s=lex();
gtsFrame=expression(registerVars,inFunction,inMethod,true,variables);
}
 else {
lexer.pushback(s);
}
ret=new GotoFrame2ActionItem(null,gtsFrame,false,false,0);
expectedType(SymbolType.PARENT_CLOSE);
break;
case NEXTFRAME:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new NextFrameActionItem(null);
break;
case PLAY:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new PlayActionItem(null);
break;
case PREVFRAME:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new PrevFrameActionItem(null);
break;
case TELLTARGET:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem tellTarget=expression(registerVars,inFunction,inMethod,true,variables);
expectedType(SymbolType.PARENT_CLOSE);
expectedType(SymbolType.CURLY_OPEN);
List<GraphTargetItem> tellcmds=commands(registerVars,inFunction,inMethod,forinlevel,variables);
expectedType(SymbolType.CURLY_CLOSE);
ret=new TellTargetActionItem(null,tellTarget,tellcmds);
break;
case STOP:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new StopActionItem(null);
break;
case STOPALLSOUNDS:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new StopAllSoundsActionItem(null);
break;
case TOGGLEHIGHQUALITY:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new ToggleHighQualityActionItem(null);
break;
case STOPDRAG:
expectedType(SymbolType.PARENT_OPEN);
expectedType(SymbolType.PARENT_CLOSE);
ret=new StopDragActionItem(null);
break;
case UNLOADMOVIE:
case UNLOADMOVIENUM:
SymbolType unloadType=s.type;
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem unTargetOrNum=expression(registerVars,inFunction,inMethod,true,variables);
expectedType(SymbolType.PARENT_CLOSE);
if (unloadType == SymbolType.UNLOADMOVIE) {
ret=new UnLoadMovieActionItem(null,unTargetOrNum);
}
if (unloadType == SymbolType.UNLOADMOVIENUM) {
ret=new UnLoadMovieNumActionItem(null,unTargetOrNum);
}
break;
case PRINT:
case PRINTASBITMAP:
case PRINTASBITMAPNUM:
case PRINTNUM:
SymbolType printType=s.type;
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem printTarget=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.COMMA);
GraphTargetItem printBBox=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.PARENT_CLOSE);
switch (printType) {
case PRINT:
ret=new PrintActionItem(null,printTarget,printBBox);
break;
case PRINTNUM:
ret=new PrintNumActionItem(null,printTarget,printBBox);
break;
case PRINTASBITMAP:
ret=new PrintAsBitmapActionItem(null,printTarget,printBBox);
break;
case PRINTASBITMAPNUM:
ret=new PrintAsBitmapNumActionItem(null,printTarget,printBBox);
break;
}
break;
case LOADVARIABLES:
case LOADMOVIE:
case LOADVARIABLESNUM:
case LOADMOVIENUM:
SymbolType loadType=s.type;
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem url2=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.COMMA);
GraphTargetItem targetOrNum=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
expected(s,lexer.yyline(),SymbolType.PARENT_CLOSE,SymbolType.COMMA);
int lvmethod=1;
if (s.type == SymbolType.COMMA) {
s=lex();
expected(s,lexer.yyline(),SymbolType.STRING);
if (s.value.equals("String_Node_Str")) {
lvmethod=2;
}
 else if (s.value.equals("String_Node_Str")) {
lvmethod=1;
}
 else {
throw new ParseException("String_Node_Str",lexer.yyline());
}
}
 else {
lexer.pushback(s);
}
expectedType(SymbolType.PARENT_CLOSE);
switch (loadType) {
case LOADVARIABLES:
ret=new LoadVariablesActionItem(null,url2,targetOrNum,lvmethod);
break;
case LOADMOVIE:
ret=new LoadMovieActionItem(null,url2,targetOrNum,lvmethod);
break;
case LOADVARIABLESNUM:
ret=new LoadVariablesNumActionItem(null,url2,targetOrNum,lvmethod);
break;
case LOADMOVIENUM:
ret=new LoadMovieNumActionItem(null,url2,targetOrNum,lvmethod);
break;
}
break;
case GOTOANDPLAY:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem gtpFrame=expression(registerVars,inFunction,inMethod,true,variables);
s=lex();
if (s.type == SymbolType.COMMA) {
s=lex();
gtpFrame=expression(registerVars,inFunction,inMethod,true,variables);
}
 else {
lexer.pushback(s);
}
ret=new GotoFrame2ActionItem(null,gtpFrame,true,false,0);
expectedType(SymbolType.PARENT_CLOSE);
break;
case REMOVEMOVIECLIP:
expectedType(SymbolType.PARENT_OPEN);
ret=new RemoveSpriteActionItem(null,(expression(registerVars,inFunction,inMethod,true,variables)));
expectedType(SymbolType.PARENT_CLOSE);
break;
case STARTDRAG:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem dragTarget=(expression(registerVars,inFunction,inMethod,true,variables));
GraphTargetItem lockCenter=null;
GraphTargetItem constrain=null;
GraphTargetItem x1=null;
GraphTargetItem y1=null;
GraphTargetItem x2=null;
GraphTargetItem y2=null;
s=lex();
if (s.type == SymbolType.COMMA) {
lockCenter=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
if (s.type == SymbolType.COMMA) {
constrain=new DirectValueActionItem(null,0,Boolean.TRUE,new ArrayList<String>());
x1=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
if (s.type == SymbolType.COMMA) {
y1=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
if (s.type == SymbolType.COMMA) {
x2=(expression(registerVars,inFunction,inMethod,true,variables));
s=lex();
if (s.type == SymbolType.COMMA) {
y2=(expression(registerVars,inFunction,inMethod,true,variables));
}
 else {
lexer.pushback(s);
y2=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
}
}
 else {
lexer.pushback(s);
x2=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
y2=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
}
}
 else {
lexer.pushback(s);
x2=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
y2=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
y1=new DirectValueActionItem(null,0,(Long)0L,new ArrayList<String>());
}
}
 else {
lexer.pushback(s);
constrain=new DirectValueActionItem(null,0,Boolean.FALSE,new ArrayList<String>());
}
}
 else {
lockCenter=new DirectValueActionItem(null,0,Boolean.FALSE,new ArrayList<String>());
constrain=new DirectValueActionItem(null,0,Boolean.FALSE,new ArrayList<String>());
lexer.pushback(s);
}
expectedType(SymbolType.PARENT_CLOSE);
ret=new StartDragActionItem(null,dragTarget,lockCenter,constrain,x1,y1,x2,y2);
break;
case IFFRAMELOADED:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem iflExpr=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.PARENT_CLOSE);
expectedType(SymbolType.CURLY_OPEN);
List<GraphTargetItem> iflComs=commands(registerVars,inFunction,inMethod,forinlevel,variables);
expectedType(SymbolType.CURLY_CLOSE);
ret=new IfFrameLoadedActionItem(iflExpr,iflComs,null);
break;
case CLASS:
GraphTargetItem classTypeStr=type(variables);
s=lex();
GraphTargetItem extendsTypeStr=null;
if (s.type == SymbolType.EXTENDS) {
extendsTypeStr=type(variables);
s=lex();
}
List<GraphTargetItem> implementsTypeStrs=new ArrayList<>();
if (s.type == SymbolType.IMPLEMENTS) {
do {
GraphTargetItem implementsTypeStr=type(variables);
implementsTypeStrs.add(implementsTypeStr);
s=lex();
}
 while (s.type == SymbolType.COMMA);
}
expected(s,lexer.yyline(),SymbolType.CURLY_OPEN);
ret=(traits(false,classTypeStr,extendsTypeStr,implementsTypeStrs,variables));
expectedType(SymbolType.CURLY_CLOSE);
break;
case INTERFACE:
GraphTargetItem interfaceTypeStr=type(variables);
s=lex();
List<GraphTargetItem> intExtendsTypeStrs=new ArrayList<>();
if (s.type == SymbolType.EXTENDS) {
do {
GraphTargetItem intExtendsTypeStr=type(variables);
intExtendsTypeStrs.add(intExtendsTypeStr);
s=lex();
}
 while (s.type == SymbolType.COMMA);
}
expected(s,lexer.yyline(),SymbolType.CURLY_OPEN);
ret=(traits(true,interfaceTypeStr,null,intExtendsTypeStrs,variables));
expectedType(SymbolType.CURLY_CLOSE);
break;
case FUNCTION:
s=lexer.lex();
expected(s,lexer.yyline(),SymbolType.IDENTIFIER);
ret=(function(true,s.value.toString(),false,variables));
break;
case NEW:
GraphTargetItem type=type(variables);
expectedType(SymbolType.PARENT_OPEN);
if (type instanceof GetMemberActionItem) {
GetMemberActionItem mem=(GetMemberActionItem)type;
ret=new NewMethodActionItem(null,mem.object,mem.memberName,call(registerVars,inFunction,inMethod,variables));
}
 else if (type instanceof VariableActionItem) {
VariableActionItem var=(VariableActionItem)type;
ret=new NewObjectActionItem(null,var,call(registerVars,inFunction,inMethod,variables));
}
 else {
ret=new NewObjectActionItem(null,ret,call(registerVars,inFunction,inMethod,variables));
}
break;
case VAR:
s=lex();
expected(s,lexer.yyline(),SymbolType.IDENTIFIER);
String varIdentifier=s.value.toString();
s=lex();
if (s.type == SymbolType.COLON) {
type(variables);
s=lex();
}
if (s.type == SymbolType.ASSIGN) {
if (!inFunction) {
}
GraphTargetItem varval=(expression(registerVars,inFunction,inMethod,true,variables));
ret=new VariableActionItem(varIdentifier,varval,true);
variables.add((VariableActionItem)ret);
}
 else {
ret=new VariableActionItem(varIdentifier,null,true);
variables.add((VariableActionItem)ret);
lexer.pushback(s);
}
break;
case CURLY_OPEN:
ret=new BlockItem(null,commands(registerVars,inFunction,inMethod,forinlevel,variables));
expectedType(SymbolType.CURLY_CLOSE);
break;
case INCREMENT:
case DECREMENT:
GraphTargetItem varincdec=variable(registerVars,inFunction,inMethod,variables);
if (s.type == SymbolType.INCREMENT) {
ret=new PreIncrementActionItem(null,varincdec);
}
 else if (s.type == SymbolType.DECREMENT) {
ret=new PreDecrementActionItem(null,varincdec);
}
break;
case IDENTIFIER:
case THIS:
case SUPER:
case PARENT_OPEN:
case EVAL:
ParsedSymbol varS=s;
boolean isEval=false;
GraphTargetItem var;
if (s.type == SymbolType.PARENT_OPEN) {
var=expression(registerVars,inFunction,inMethod,true,variables);
expectedType(SymbolType.PARENT_CLOSE);
memberOrCall(var,registerVars,inFunction,inMethod,variables);
}
 else if (s.type == SymbolType.EVAL) {
expectedType(SymbolType.PARENT_OPEN);
var=expression(registerVars,inFunction,inMethod,true,variables);
var=new EvalActionItem(null,var);
expectedType(SymbolType.PARENT_CLOSE);
var=memberOrCall(var,registerVars,inFunction,inMethod,variables);
isEval=true;
}
 else {
lexer.pushback(s);
var=variable(registerVars,inFunction,inMethod,variables);
}
s=lex();
switch (s.type) {
case ASSIGN:
ret=var;
ret=Action.gettoset(ret,expression(registerVars,inFunction,inMethod,true,variables),variables);
break;
case ASSIGN_BITAND:
case ASSIGN_BITOR:
case ASSIGN_DIVIDE:
case ASSIGN_MINUS:
case ASSIGN_MODULO:
case ASSIGN_MULTIPLY:
case ASSIGN_PLUS:
case ASSIGN_SHIFT_LEFT:
case ASSIGN_SHIFT_RIGHT:
case ASSIGN_USHIFT_RIGHT:
case ASSIGN_XOR:
GraphTargetItem valtoappend=(expression(registerVars,inFunction,inMethod,true,variables));
switch (s.type) {
case ASSIGN_BITAND:
ret=Action.gettoset(var,new BitAndActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_BITOR:
ret=Action.gettoset(var,new BitOrActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_DIVIDE:
ret=Action.gettoset(var,new DivideActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_MINUS:
ret=Action.gettoset(var,new SubtractActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_MODULO:
ret=Action.gettoset(var,new ModuloActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_MULTIPLY:
ret=Action.gettoset(var,new MultiplyActionItem(null,var,valtoappend),variables);
break;
case ASSIGN_PLUS:
ret=Action.gettoset(var,new AddActionItem(null,var,valtoappend,true),variables);
break;
}
break;
case INCREMENT:
ret=new PostIncrementActionItem(null,var);
break;
case DECREMENT:
ret=new PostDecrementActionItem(null,var);
break;
case PARENT_OPEN:
ret=var;
if (varS.type == SymbolType.SUPER || varS.type == SymbolType.THIS && (var instanceof VariableActionItem)) {
List<GraphTargetItem> args=call(registerVars,inFunction,inMethod,variables);
ret=new CallMethodActionItem(null,ret,new DirectValueActionItem(null,0,new Undefined(),constantPool),args);
}
 else {
lexer.pushback(s);
ret=memberOrCall(ret,registerVars,inFunction,inMethod,variables);
}
break;
default :
if (isEval) {
ret=var;
}
 else {
if (mustBeCommand) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
}
}
break;
case IF:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem ifExpr=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.PARENT_CLOSE);
GraphTargetItem onTrue=command(registerVars,inFunction,inMethod,forinlevel,true,variables);
List<GraphTargetItem> onTrueList=new ArrayList<>();
onTrueList.add(onTrue);
s=lex();
List<GraphTargetItem> onFalseList=null;
if (s.type == SymbolType.ELSE) {
onFalseList=new ArrayList<>();
onFalseList.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
}
 else {
lexer.pushback(s);
}
ret=new IfItem(null,ifExpr,onTrueList,onFalseList);
break;
case WHILE:
expectedType(SymbolType.PARENT_OPEN);
List<GraphTargetItem> whileExpr=new ArrayList<>();
whileExpr.add(commaExpression(registerVars,inFunction,inMethod,forinlevel,variables));
expectedType(SymbolType.PARENT_CLOSE);
List<GraphTargetItem> whileBody=new ArrayList<>();
whileBody.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
ret=new WhileItem(null,null,whileExpr,whileBody);
break;
case DO:
List<GraphTargetItem> doBody=new ArrayList<>();
doBody.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
expectedType(SymbolType.WHILE);
expectedType(SymbolType.PARENT_OPEN);
List<GraphTargetItem> doExpr=new ArrayList<>();
doExpr.add(commaExpression(registerVars,inFunction,inMethod,forinlevel,variables));
expectedType(SymbolType.PARENT_CLOSE);
ret=new DoWhileItem(null,null,doBody,doExpr);
break;
case FOR:
expectedType(SymbolType.PARENT_OPEN);
s=lex();
boolean forin=false;
GraphTargetItem collection=null;
String objIdent=null;
int innerExprReg=0;
if (s.type == SymbolType.VAR || s.type == SymbolType.IDENTIFIER) {
ParsedSymbol s2=null;
ParsedSymbol ssel=s;
if (s.type == SymbolType.VAR) {
s2=lex();
ssel=s2;
}
if (ssel.type == SymbolType.IDENTIFIER) {
objIdent=ssel.value.toString();
ParsedSymbol s3=lex();
if (s3.type == SymbolType.IN) {
if (inFunction) {
for (int i=0; i < 256; i++) {
if (!registerVars.containsValue(i)) {
registerVars.put(objIdent,i);
innerExprReg=i;
break;
}
}
}
collection=expression(registerVars,inFunction,inMethod,true,variables);
forin=true;
}
 else {
lexer.pushback(s3);
if (s2 != null) {
lexer.pushback(s2);
}
lexer.pushback(s);
}
}
 else {
if (s2 != null) {
lexer.pushback(s2);
}
lexer.pushback(s);
}
}
 else {
lexer.pushback(s);
}
List<GraphTargetItem> forFinalCommands=new ArrayList<>();
GraphTargetItem forExpr=null;
List<GraphTargetItem> forFirstCommands=new ArrayList<>();
if (!forin) {
forFirstCommands.add((command(registerVars,inFunction,inMethod,forinlevel,true,variables)));
forExpr=(expression(registerVars,inFunction,inMethod,true,variables));
expectedType(SymbolType.SEMICOLON);
forFinalCommands.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
}
expectedType(SymbolType.PARENT_CLOSE);
List<GraphTargetItem> forBody=new ArrayList<>();
forBody.add(command(registerVars,inFunction,inMethod,forin ? forinlevel + 1 : forinlevel,true,variables));
if (forin) {
ret=new ForInActionItem(null,null,pushConst(objIdent),collection,forBody);
}
 else {
ret=new ForItem(null,null,forFirstCommands,forExpr,forFinalCommands,forBody);
}
break;
case SWITCH:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem switchExpr=expression(registerVars,inFunction,inMethod,true,variables);
expectedType(SymbolType.PARENT_CLOSE);
expectedType(SymbolType.CURLY_OPEN);
s=lex();
int exprReg=0;
for (int i=0; i < 256; i++) {
if (!registerVars.containsValue(i)) {
registerVars.put("String_Node_Str" + uniqId(),i);
exprReg=i;
break;
}
}
List<List<ActionIf>> caseIfs=new ArrayList<>();
List<List<GraphTargetItem>> caseCmds=new ArrayList<>();
List<GraphTargetItem> caseExprsAll=new ArrayList<>();
List<Integer> valueMapping=new ArrayList<>();
int pos=0;
while (s.type == SymbolType.CASE) {
List<GraphTargetItem> caseExprs=new ArrayList<>();
while (s.type == SymbolType.CASE) {
GraphTargetItem curCaseExpr=expression(registerVars,inFunction,inMethod,true,variables);
caseExprs.add(curCaseExpr);
expectedType(SymbolType.COLON);
s=lex();
caseExprsAll.add(curCaseExpr);
valueMapping.add(pos);
}
pos++;
lexer.pushback(s);
List<GraphTargetItem> caseCmd=commands(registerVars,inFunction,inMethod,forinlevel,variables);
caseCmds.add(caseCmd);
s=lex();
}
List<GraphTargetItem> defCmd=new ArrayList<>();
if (s.type == SymbolType.DEFAULT) {
expectedType(SymbolType.COLON);
defCmd=commands(registerVars,inFunction,inMethod,forinlevel,variables);
s=lexer.lex();
}
expected(s,lexer.yyline(),SymbolType.CURLY_CLOSE);
ret=new SwitchItem(null,null,switchExpr,caseExprsAll,caseCmds,defCmd,valueMapping);
break;
case BREAK:
ret=new BreakItem(null,0);
break;
case CONTINUE:
ret=new ContinueItem(null,0);
break;
case RETURN:
GraphTargetItem retexpr=expression(true,registerVars,inFunction,inMethod,true,variables);
if (retexpr == null) {
retexpr=new DirectValueActionItem(null,0,new Undefined(),new ArrayList<String>());
}
ret=new ReturnActionItem(null,retexpr);
break;
case TRY:
List<GraphTargetItem> tryCommands=new ArrayList<>();
tryCommands.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
s=lex();
boolean found=false;
List<List<GraphTargetItem>> catchCommands=null;
List<GraphTargetItem> catchExceptions=new ArrayList<>();
if (s.type == SymbolType.CATCH) {
expectedType(SymbolType.PARENT_OPEN);
s=lex();
expected(s,lexer.yyline(),SymbolType.IDENTIFIER,SymbolType.STRING);
catchExceptions.add(pushConst((String)s.value));
expectedType(SymbolType.PARENT_CLOSE);
catchCommands=new ArrayList<>();
List<GraphTargetItem> cc=new ArrayList<>();
cc.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
catchCommands.add(cc);
s=lex();
found=true;
}
List<GraphTargetItem> finallyCommands=null;
if (s.type == SymbolType.FINALLY) {
finallyCommands=new ArrayList<>();
finallyCommands.add(command(registerVars,inFunction,inMethod,forinlevel,true,variables));
found=true;
s=lex();
}
if (!found) {
expected(s,lexer.yyline(),SymbolType.CATCH,SymbolType.FINALLY);
}
lexer.pushback(s);
ret=new TryActionItem(tryCommands,catchExceptions,catchCommands,finallyCommands);
break;
case THROW:
ret=new ThrowActionItem(null,expression(registerVars,inFunction,inMethod,true,variables));
break;
default :
GraphTargetItem valcmd=expressionCommands(s,registerVars,inFunction,inMethod,forinlevel,variables);
if (valcmd != null) {
ret=valcmd;
break;
}
if (s.type != SymbolType.SEMICOLON) {
lexer.pushback(s);
}
if (debugMode) {
System.out.println("String_Node_Str");
}
return null;
}
s=lex();
if ((s != null) && (s.type != SymbolType.SEMICOLON)) {
lexer.pushback(s);
}
if (debugMode) {
System.out.println("String_Node_Str");
}
if (ret == null && (!mustBeCommand)) {
buf.pushAllBack(lexer);
}
lexer.removeListener(buf);
return ret;
}