public static void FinalParse(Dsl.DslInfo dslInfo) { string id = dslInfo.GetId(); if (id == "command") { if (dslInfo.Functions.Count == 2) { Dsl.FunctionData first = dslInfo.First; string name = first.Call.GetParamId(0); IStoryCommandFactory factory = StoryCommandManager.Instance.FindFactory(name); if (null != factory) { StorySystem.CommonCommands.CompositeCommand cmd = factory.Create() as StorySystem.CommonCommands.CompositeCommand; Dsl.FunctionData second = dslInfo.Second; cmd.InitialCommands.Clear(); for (int ix = 0; ix < second.GetStatementNum(); ++ix) { Dsl.ISyntaxComponent syntaxComp = second.GetStatement(ix); IStoryCommand sub = StoryCommandManager.Instance.CreateCommand(syntaxComp); cmd.InitialCommands.Add(sub); } } else { LogSystem.Error("Can't find command factory '{0}'", name); } } } else if (id == "value") { if (dslInfo.Functions.Count == 3) { Dsl.FunctionData first = dslInfo.First; string name = first.Call.GetParamId(0); IStoryValueFactory factory = StoryValueManager.Instance.FindFactory(name); if (null != factory) { StorySystem.CommonValues.CompositeValue val = factory.Build() as StorySystem.CommonValues.CompositeValue; Dsl.FunctionData second = dslInfo.Second; Dsl.FunctionData third = dslInfo.Functions[2]; val.InitialCommands.Clear(); for (int ix = 0; ix < third.GetStatementNum(); ++ix) { Dsl.ISyntaxComponent syntaxComp = third.GetStatement(ix); IStoryCommand sub = StoryCommandManager.Instance.CreateCommand(syntaxComp); val.InitialCommands.Add(sub); } } else { LogSystem.Error("Can't find value factory '{0}'", name); } } } }
public static void FinalParse(Dsl.ISyntaxComponent dslInfo) { string id = dslInfo.GetId(); if (id == "command") { string name = string.Empty; var first = dslInfo as Dsl.FunctionData; var statement = dslInfo as Dsl.StatementData; if (null != first) { name = first.Call.GetParamId(0); } else { if (null != statement) { first = statement.First; name = first.Call.GetParamId(0); } } IStoryCommandFactory factory = StoryCommandManager.Instance.FindFactory(name); if (null != factory) { StorySystem.CommonCommands.CompositeCommand cmd = factory.Create() as StorySystem.CommonCommands.CompositeCommand; cmd.InitialCommands.Clear(); Dsl.FunctionData bodyFunc = null; if (null != statement) { for (int i = 0; i < statement.GetFunctionNum(); ++i) { var funcData = statement.GetFunction(i); var fid = funcData.GetId(); if (funcData.HaveStatement() && fid != "opts") { bodyFunc = funcData; } } } else { bodyFunc = first; } if (null != bodyFunc) { for (int ix = 0; ix < bodyFunc.GetStatementNum(); ++ix) { Dsl.ISyntaxComponent syntaxComp = bodyFunc.GetStatement(ix); IStoryCommand sub = StoryCommandManager.Instance.CreateCommand(syntaxComp); cmd.InitialCommands.Add(sub); } } else { LogSystem.Error("Can't find command {0}'s body", name); } } else { LogSystem.Error("Can't find command {0}'s factory", name); } } else if (id == "value") { string name = string.Empty; var first = dslInfo as Dsl.FunctionData; var statement = dslInfo as Dsl.StatementData; if (null != first) { name = first.Call.GetParamId(0); } else { if (null != statement) { first = statement.First; name = first.Call.GetParamId(0); } } IStoryValueFactory factory = StoryValueManager.Instance.FindFactory(name); if (null != factory) { StorySystem.CommonValues.CompositeValue val = factory.Build() as StorySystem.CommonValues.CompositeValue; val.InitialCommands.Clear(); Dsl.FunctionData bodyFunc = null; if (null != statement) { for (int i = 0; i < statement.GetFunctionNum(); ++i) { var funcData = statement.GetFunction(i); var fid = funcData.GetId(); if (funcData.HaveStatement() && fid != "opts") { bodyFunc = funcData; } } } else { bodyFunc = first; } if (null != bodyFunc) { for (int ix = 0; ix < bodyFunc.GetStatementNum(); ++ix) { Dsl.ISyntaxComponent syntaxComp = bodyFunc.GetStatement(ix); IStoryCommand sub = StoryCommandManager.Instance.CreateCommand(syntaxComp); val.InitialCommands.Add(sub); } } else { LogSystem.Error("Can't find value {0}'s body", name); } } else { LogSystem.Error("Can't find value {0}'s factory", name); } } }
public static void FinalParse(Dsl.DslInfo dslInfo) { string id = dslInfo.GetId(); if (id == "command") { Dsl.FunctionData first = dslInfo.First; string name = first.Call.GetParamId(0); IStoryCommandFactory factory = StoryCommandManager.Instance.FindFactory(name); if (null != factory) { StorySystem.CommonCommands.CompositeCommand cmd = factory.Create() as StorySystem.CommonCommands.CompositeCommand; cmd.InitialCommands.Clear(); Dsl.FunctionData last = dslInfo.Last; var bodyId = last.GetId(); if (bodyId == "body" || bodyId != "opts") { for (int ix = 0; ix < last.GetStatementNum(); ++ix) { Dsl.ISyntaxComponent syntaxComp = last.GetStatement(ix); IStoryCommand sub = StoryCommandManager.Instance.CreateCommand(syntaxComp); cmd.InitialCommands.Add(sub); } } else { LogSystem.Error("Can't find command body '{0}'", name); } } else { LogSystem.Error("Can't find command factory '{0}'", name); } } else if (id == "value") { Dsl.FunctionData first = dslInfo.First; string name = first.Call.GetParamId(0); IStoryValueFactory factory = StoryValueManager.Instance.FindFactory(name); if (null != factory) { StorySystem.CommonValues.CompositeValue val = factory.Build() as StorySystem.CommonValues.CompositeValue; val.InitialCommands.Clear(); Dsl.FunctionData last = dslInfo.Last; var bodyId = last.GetId(); if (bodyId == "body" || bodyId != "opts") { for (int ix = 0; ix < last.GetStatementNum(); ++ix) { Dsl.ISyntaxComponent syntaxComp = last.GetStatement(ix); IStoryCommand sub = StoryCommandManager.Instance.CreateCommand(syntaxComp); val.InitialCommands.Add(sub); } } else { LogSystem.Error("Can't find value body '{0}'", name); } } else { LogSystem.Error("Can't find value factory '{0}'", name); } } }