public void Parse(ref string[] program) { IfConditionBlock ifConditionBlock = new IfConditionBlock(); ifConditionBlock.Parse(ref program); _IfBlock.Add(ifConditionBlock); string token = ParseUtils.PeekToken(program); while (token.Equals("else", StringComparison.Ordinal)) { string elsestring = ParseUtils.GetToken(ref program); if (!elsestring.Equals("else", StringComparison.Ordinal)) { throw new ParseException("missing else statement, found " + elsestring + " instead."); } string iftoken = ParseUtils.PeekToken(program); if (iftoken.Equals("if", StringComparison.Ordinal)) { IfConditionBlock ifCondBlock = new IfConditionBlock(); ifCondBlock.Parse(ref program); _IfBlock.Add(ifCondBlock); } else { _ElseBlock = new RuleBlock(); _ElseBlock.Parse(ref program); return; // no more blocks allowed... } token = ParseUtils.PeekToken(program); } }
public void Parse(ref string[] program) { IfConditionBlock ifConditionBlock = new IfConditionBlock(); ifConditionBlock.Parse(ref program); _IfBlock.Add(ifConditionBlock); string token = ParseUtils.PeekToken(program); while (token.Equals("else", StringComparison.Ordinal)) { string elsestring = ParseUtils.GetToken(ref program); if (!elsestring.Equals("else", StringComparison.Ordinal)) throw new ParseException("missing else statement, found " + elsestring + " instead."); string iftoken = ParseUtils.PeekToken(program); if (iftoken.Equals("if", StringComparison.Ordinal)) { IfConditionBlock ifCondBlock = new IfConditionBlock(); ifCondBlock.Parse(ref program); _IfBlock.Add(ifCondBlock); } else { _ElseBlock = new RuleBlock(); _ElseBlock.Parse(ref program); return; // no more blocks allowed... } token = ParseUtils.PeekToken(program); } }