internal Variable ProcessSwitch(ParsingScript script) { Variable switchValue = Utils.GetItem(script); script.Forward(); Variable result = Variable.EmptyInstance; var caseSep = ":".ToCharArray(); bool caseDone = false; while (script.StillValid()) { var nextToken = Utils.GetBodySize(script, Constants.CASE, Constants.DEFAULT); if (string.IsNullOrEmpty(nextToken)) { break; } if (nextToken == Constants.DEFAULT && !caseDone) { result = ProcessBlock(script); break; } if (!caseDone) { Variable caseValue = script.Execute(caseSep); script.Forward(); if (switchValue.Type == caseValue.Type && switchValue.Equals(caseValue)) { caseDone = true; result = ProcessBlock(script); if (script.Prev == '}') { break; } script.Forward(); } } } script.MoveForwardIfNotPrevious('}'); script.GoToNextStatement(); return(result); }