public override void parseBlocks(string input) { DelimiterText = getInternalBlockText(DELIMITER, input); ParameterText = getInternalBlockText(PARAMETERS, input); CreationText = getInternalBlockText(TEXT, input); //Parse Delimiter Delimiter = new String[] { ProgramNode.loadString(DelimiterText) }; //Parse Parameter Text VarList = ParameterText.Split(ProgramNode.NEWLINE, StringSplitOptions.RemoveEmptyEntries).Select(x => ProgramNode.loadString(x)).ToList(); }
/// <summary> /// If the parameter text is of the form /// separator char, then entries, returns the number of parameters /// </summary> /// <returns></returns> protected List <string> Parameters() { var ans = new List <string>(); if (!string.IsNullOrEmpty(ParameterText)) { var sep = ParameterText[0]; var words = ParameterText.Split(new[] { sep }); ans.AddRange(words); } return(ans); }
public override void parseBlocks(string input) { DelimiterText = getInternalBlockText(DELIMITER, input); ParameterText = getInternalBlockText(PARAMETERS, input); ConditionalText = getInternalBlockText(CONDITIONALS, input); CreationText = getInternalBlockText(TEXT, input); //Parse Delimiter Delimiter = new String[] { ProgramNode.loadString(DelimiterText) }; //Parse Parameter Text VarList = ParameterText.Split(ProgramNode.NEWLINE, StringSplitOptions.RemoveEmptyEntries).Select(x => ProgramNode.loadString(x)).ToList(); var cSplit = ConditionalText.Split(ProgramNode.NEWLINE, StringSplitOptions.RemoveEmptyEntries).Select(x => ProgramNode.loadString(x)).ToList(); Conditionals = new List <Conditional>(); Conditional workingConditional = new Conditional(); foreach (String line in cSplit) { if (workingConditional.varName.Length == 0) { //Set the varname to the first line workingConditional.varName = line; continue; } else if (line.Contains(NEXT)) { //This is a NEXT Statement, to advance the variable Conditionals.Add(workingConditional); workingConditional = new Conditional(); continue; } else { //The format of the line: //VAR_LOOKUP | CONDITION | VAR_VALUE String[] cLineSplit = line.Split(ProgramNode.BAR, StringSplitOptions.RemoveEmptyEntries); if (cLineSplit.Length >= 2) { //Size 2 is allowed, because text can be blank if (VarList.Contains(cLineSplit[0])) { workingConditional.varLookups.Add(VarList.IndexOf(cLineSplit[0])); } else { //Attempt to parse this as an integer workingConditional.varLookups.Add(ProgramNode.loadInt(cLineSplit[0])); } //Attept to load condition Condition c = Condition.loadCondition(cLineSplit[1]); workingConditional.conditions.Add(c); String result = ""; if (cLineSplit.Length >= 3) { result = ProgramNode.loadString(cLineSplit[2]); } workingConditional.values.Add(result); } } } }