public FiMClass(string name, bool main = false, FiMClass parent = null, FiMReport report = null) { this.Variables = new FiMVariableList(); this.Paragraphs = new Stack <FiMParagraph>(); this.Classes = new Stack <FiMClass>(); this.Name = name; this.IsMain = main; if (this.IsMain) { this.Report = report; this.Parent = parent; } }
public static ArrayIndex GetArrayIndex(string content, FiMClass reportClass) { // Explicit index if (Regex.IsMatch(content, @"^(.+) of (.+)$")) { var match = Regex.Match(content, @"^(.+) (of) (.+)$"); if (!FiMHelper.IsIndexInsideString(content, match.Groups[2].Index)) { string strIndex = match.Groups[1].Value; string strVar = match.Groups[3].Value; if (reportClass.GetVariable(strVar) != null) { return(new ArrayIndex() { RawIndex = strIndex, RawVariable = strVar }); } } } // Implicit index if (Regex.IsMatch(content, @"^(.+) (\d+)$")) { var match = Regex.Match(content, @"^(.+) (\d+)$"); string varName = match.Groups[1].Value; string varIndex = match.Groups[2].Value; if (reportClass.GetVariable(varName) != null) { return(new ArrayIndex() { RawIndex = varIndex, RawVariable = varName, }); } } return(null); }
internal static void ParseClass(FiMClass c, KirinNode[] nodes, string content) { for (int i = 0; i < nodes.Length; i++) { var node = nodes[i]; switch (node.NodeType) { case "KirinFunctionStart": { i++; var startNode = node as KirinFunctionStart; List <KirinNode> funcNodes = new List <KirinNode>(); while (nodes[i].NodeType != "KirinFunctionEnd") { funcNodes.Add(nodes[i]); i++; } var statement = ParseStatement(funcNodes.ToArray(), content); var endNode = nodes[i] as KirinFunctionEnd; var func = ParseFunction(startNode, endNode, statement); if (func.Today && c.GetType() == typeof(FiMReport)) { var n = (FiMReport)c; if (n._MainParagraph != string.Empty) { throw new Exception("Multiple main methods found"); } n._MainParagraph = func.Name; } c.AddParagraph(new FiMParagraph(c, func)); } break; case "KirinVariableDeclaration": { ((KirinVariableDeclaration)node).Execute(c, true); } break; // "KirinClassDeclarationStart": case "KirinPostScript": { // Ignore } break; default: { var line = FiMHelper.GetIndexPair(content, node.Start).Line; throw new Exception($"Illegal class body node at line {line}"); } } } }
public FiMParagraph(FiMClass rClass, KirinBaseFunction func) { this.reportClass = rClass; this.Function = func; this.Name = func.Name; }
public static bool IsArrayIndex(string content, FiMClass reportClass) { return(GetArrayIndex(content, reportClass) != null); }