public static int RefToOffset(List <Binding> bs, GPLCSource subBlock, int mode, List <string> errorLog) { int n; for (n = 0; n <= bs.Count; n++) { if (n == bs.Count && mode == 0) { errorLog.Add("\n\nError at line " + Convert.ToString(subBlock.line) + " column " + Convert.ToString(subBlock.column) + " (in code block). " + subBlock.content + " is an undeclared reference argument."); } else if (n == bs.Count && mode == 1) { errorLog.Add("\n\nError at line " + Convert.ToString(subBlock.line) + " column " + Convert.ToString(subBlock.column) + " (in code block). " + subBlock.content + " is an undeclared reference argument."); } else if (n == bs.Count && mode == 2) { errorLog.Add("\n\nError at line " + Convert.ToString(subBlock.line) + " column " + Convert.ToString(subBlock.column) + " (in map structure data). " + subBlock.content + " is an undeclared reference argument."); } else if (bs[n].symbol == subBlock.content) { if (mode == 0) { return(bs[n].readIndex); } else { return(bs[n].writeIndex); } } else { } } return(0); }
public static int ReadLiteral(GPLCSource subBlock, List <string> errorLog, int mode) { string errorDetail; try { return(Convert.ToInt32(subBlock.content)); } catch (FormatException) { errorDetail = "\n\nError at line " + Convert.ToString(subBlock.line) + " column " + Convert.ToString(subBlock.column); if (mode == 0) { errorDetail = errorDetail + " (in value block). The second term in a value initialisation must be an integer. For details of how non - integer arguments are handled see the Op - code arguments section of the GPLC specification."; } else if (mode == 1) { errorDetail = errorDetail + " (in code block). This opcode argument must be a literal integer."; } else { errorDetail = errorDetail + " (in map structure data). The second term in a value patch must be an integer."; } errorLog.Add(errorDetail); } return(0); }
private static GPLCSource BuildSubBlock(string sourceIn, int i, int l, int c) { List <char> content = new List <char>(); GPLCSource subBlock = new GPLCSource(); for ( ; i < sourceIn.Length; i++) { if (sourceIn[i] == ' ' || (sourceIn[i] == '\r' && sourceIn[i + 1] == '\n')) { break; } else { content.Add(sourceIn[i]); } } subBlock.content = string.Join("", content); subBlock.line = l + 1; subBlock.column = c + 1; return(subBlock); }