コード例 #1
0
 public override LoliBool Eval()
 {
     if (Statment != null)
     {
         return(Statment.Apply(Left, Right));
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
 public virtual T Eval()
 {
     if (Statment == null)
     {
         return(Value);
     }
     else
     {
         return(Statment.Apply(Left, Right));
     }
 }
コード例 #3
0
ファイル: Assembler.cs プロジェクト: pedromsantos/DCPU16.Net
        public IList<ushort> AssembleStatments(IEnumerable<Statment> statments)
        {
            foreach (var statment in statments)
            {
                this.currentStatment = statment;
                this.AssembleStatment();
            }

            this.ResolveLabelReferences();

            return this.program;
        }
コード例 #4
0
ファイル: Scope.cs プロジェクト: DrunkerScripter/RSS
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
ファイル: RSSParser.cs プロジェクト: DrunkerScripter/RSS
        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();
        }
コード例 #7
0
        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;
        }
コード例 #8
0
ファイル: Scope.cs プロジェクト: DrunkerScripter/RSS
        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);
        }
コード例 #9
0
 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();
         }
     }
 }
コード例 #10
0
        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);
        }
コード例 #11
0
ファイル: Scope.cs プロジェクト: DrunkerScripter/RSS
        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;
            }
        }
コード例 #12
0
ファイル: Scope.cs プロジェクト: DrunkerScripter/RSS
        private void ProcessStyleScope(string Line, string[] details, Statment ID)
        {
            StyleScope sc = (StyleScope)ID.Generate(Line, (Scopes.Count == 0 ? this : Scopes.Peek()));

            Scopes.Push(sc);
        }