public override LoliBool Eval() { if (Statment != null) { return(Statment.Apply(Left, Right)); } else { return(false); } }
public virtual T Eval() { if (Statment == null) { return(Value); } else { return(Statment.Apply(Left, Right)); } }
public IList<ushort> AssembleStatments(IEnumerable<Statment> statments) { foreach (var statment in statments) { this.currentStatment = statment; this.AssembleStatment(); } this.ResolveLabelReferences(); return this.program; }
private void ProcessStyleId(string[] details, Statment stat) { if (Scopes.Count == 0) { throw new ParserException("Can't open a style id this scope."); } StyleIdScope StScope = (StyleIdScope)stat.Generate(null, (Scopes.Count == 0 ? this : Scopes.Peek())); StScope.ClassNames = details; Scopes.Push(StScope); }
private static void QueryAsync(Statment statement) { MySqlConnection c = new MySqlConnection(strConnection); c.Open(); MySqlCommand cmd = c.CreateCommand(); cmd.CommandText = statement.query; foreach (KeyValuePair <string, object> entry in statement.parameters) { cmd.Parameters.AddWithValue(entry.Key, entry.Value); } cmd.Prepare(); cmd.BeginExecuteNonQuery(new AsyncCallback(QueryAsyncCallback), new QueryObject <bool>(null, cmd)); }
private void ProcessLine() { string str = Line.ToString().Trim(); Statment ID = StatmentManager.GetLineType(str); if (ID.ID == StatmentType.Unknown) { throw new ParserException($"Unkown Line '{str}'"); } Program.AddStatment(ID, str); Line.Clear(); }
private void LoadTemplate() { Actual_statment = Statements.PickRandom(); if (Actual_statment.Answer != 2) { Actual_statment = Statements.PickRandom(); } if (Actual_statment.Answer != 2) { Actual_statment = Statements.PickRandom(); } lblTopic.Text = Actual_statment.Question; txtTemplate.Text = Answer_original; }
private void ProcessCustomWidgetScope(string Line, Statment Stat, string[] details) { RSSInstance CustomInstance; if (!Parser.TryGetWidget(details[0], out CustomInstance)) { throw new ParserException($"No custom widget named {details[0]}"); } RSSInstance Instance = new RSSInstance(CustomInstance.ClassName, details[0], CustomInstance.Name); WidgetScope sc = (WidgetScope)Stat.Generate(Line, (Scopes.Count == 0 ? this : Scopes.Peek())); sc.Instance = Instance; Scopes.Push(sc); }
private static void Query(Statment statement) { using (MySqlConnection c = new MySqlConnection(strConnection)) { c.Open(); using (MySqlCommand cmd = c.CreateCommand()) { cmd.CommandText = statement.query; foreach (KeyValuePair <string, object> entry in statement.parameters) { cmd.Parameters.AddWithValue(entry.Key, entry.Value); } cmd.Prepare(); cmd.ExecuteNonQuery(); } } }
private static DataTable Read(Statment statement) { DataTable retVal = new DataTable(); using (MySqlConnection c = new MySqlConnection(strConnection)) { c.Open(); using (MySqlCommand cmd = c.CreateCommand()) { cmd.CommandText = statement.query; foreach (KeyValuePair <string, object> entry in statement.parameters) { cmd.Parameters.AddWithValue(entry.Key, entry.Value); } cmd.Prepare(); retVal.Load(cmd.ExecuteReader()); } } return(retVal); }
internal void AddStatment(Statment Stat, string line) { if (Stat == null) { // Console.WriteLine($"Unkown statment '{line}'"); return; } //Check for the mismatch of a type. if (Scopes.Count > 0) { if (Stat.ID != StatmentType.ScopeEnding && Stat.ID != StatmentType.Any) { if (!Scopes.Peek().AcceptsStatmentType(Stat.ID)) { throw new ParserException("Attempted to open an unaccepted scope"); } } } string[] details = Stat.GetDetails(line); switch (Stat.ID) { case StatmentType.Variable: ProcessVariable(Stat.GetDetails(line)); break; case StatmentType.ScopeEnding: CloseScope(); break; case StatmentType.PropertyAssignment: ProcessPropertyAssignment(details, Scopes.Peek()); break; case StatmentType.CustomWidgetScopeOpening: ProcessCustomWidgetScope(line, Stat, details); //Check the custom class exsists. break; case StatmentType.StyleScopeOpening: ProcessStyleScope(line, details, Stat); break; case StatmentType.StyleIdOpening: ProcessStyleId(details, Stat); break; default: bool isCustom = line.StartsWith("widget"); RSSInstance Instance = new RSSInstance(details[0], details[1], isCustom); WidgetScope sc = (WidgetScope)Stat.Generate(line, (Scopes.Count == 0 ? this : Scopes.Peek())); sc.Instance = Instance; Scopes.Push(sc); break; } }
private void ProcessStyleScope(string Line, string[] details, Statment ID) { StyleScope sc = (StyleScope)ID.Generate(Line, (Scopes.Count == 0 ? this : Scopes.Peek())); Scopes.Push(sc); }