public override IElement CreateCopy() { CaseSwitchStatement e = new CaseSwitchStatement(); e.AddChildren(this.CopyChildren()); return(e); }
private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo) { CaseSwitchStatement caseSwitch = new CaseSwitchStatement(); MoveInfo moveInfo = new MoveInfo(parentInfo); // expression IElement next = moveInfo.FindNextBlack(SearchDirection.LeftToRight); Expression exp = Expression.Parse(moveInfo, parsingInfo, scriptInfo); if (exp == null) { throw new SyntaxException("Could not parse case expression", parentInfo.GetErrorInfo()); } // terminal IElement tryTerminal = moveInfo.FindNextBlack(SearchDirection.LeftToRight); if (tryTerminal == null || !tryTerminal.IsTT(TokenType.Colon)) { throw new SyntaxException("Missing directive ':'?", parentInfo.GetErrorInfo()); } // statements IElement nextStatement = moveInfo.FindNextBlack(SearchDirection.LeftToRight); while (nextStatement != null) // end of switch { if (CaseSwitchStatement.Check(moveInfo, parsingInfo, scriptInfo, false) || DefaultSwitchStatement.Check(moveInfo, parsingInfo, scriptInfo, false)) { break; } Statement.Check(moveInfo, parsingInfo, scriptInfo); nextStatement = moveInfo.FindNextBlack(SearchDirection.LeftToRight); } // build int startIndex = parentInfo.CurrentIndex; int length = (moveInfo.CurrentIndex) - startIndex; caseSwitch.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length)); parentInfo.Replace(length, caseSwitch); }