示例#1
0
        /// <summary>
        /// Gets list of the items to be put to the context choice list.
        /// </summary>
        /// <returns></returns>
        private ICollection GetList()
        {
            // Gets neares context choice list "dropper"
            ILexem lexem = FindDropper();

            ArrayList list = new ArrayList();

            if (lexem == null)
            {
                return(list);
            }

            // Adds to the resulting list all lexeme configuratios with "Method" and "Property" formats.
            foreach (IConfigLexem confLex in lexem.Config.SubLexems)
            {
                if (confLex.Format.Name == "Method")
                {
                    list.Add(confLex);
                }

                if (confLex.Format.Name == "Property")
                {
                    list.Add(confLex);
                }
            }

            return(list);
        }
示例#2
0
        /// <summary>
        /// Fills context prompt menu.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editControl1_ContextPromptOpen(object sender, Syncfusion.Windows.Forms.Edit.ContextPromptUpdateEventArgs e)
        {
            // First of all we should get lexem(if it is one),
            // which opens current region that supports context prompt dropping.
            ILexem lex = GetCurrentContextPromptDropper();

            if (lex == null)
            {
                // If there is no such lexem, than we should not show context prompt.
                e.CloseForm = true;
                return;
            }

            IConfigLexem conf = lex.Config.ParentConfig;

            // If there is no prompts assigned to the found complex lexem, than we should exit.
            if (!m_MethodPrompts.Contains(conf.ID))
            {
                return;
            }

            DictionaryEntry[] prompts = ( DictionaryEntry[] )m_MethodPrompts[conf.ID];
            e.List.Clear();
            // add prompts
            foreach (DictionaryEntry entry in prompts)
            {
                // Creates new context prompt item and adds it to the list of the prompts.
                ContextPromptItem itemNew = e.List.Add((string)entry.Key, (string)entry.Value);
                // Parses subject of the item, splits it to the set of method parameters
                // and adds every parameter as boldable item to the context prompt item.
                ParseContectPromptSubject(itemNew);
            }
        }
示例#3
0
        private void editControl1_ContextPromptBeforeOpen(object sender, System.ComponentModel.CancelEventArgs e)
        {
            ILexemLine lexemLine = this.editControl1.GetLine(this.editControl1.CurrentLine);

            //Gets the index of the current word in that line
            int ind = GetContextPromptCharIndex(lexemLine);

            if (ind <= 0)
            {
                e.Cancel = true;
                return;
            }
            ILexem lex = lexemLine.LineLexems[ind - 1] as ILexem;

            // If the count is less than '2', do not show the ContextPrompt popup
            if (lexemLine.LineLexems.Count < 2)
            {
                e.Cancel = true;
            }
            else
            {
                // Display ContextChoice popup if the lexem used to invoke them is "this" or "me" only
                if ((lex.Text == "Chat") || (lex.Text == "Database") || (lex.Text == "NewFile") || (lex.Text == "Find") || (lex.Text == "Home") || (lex.Text == "PieChart") || (lex.Text == "Tools"))
                {
                    this.contextPromptLexem = lex.Text;
                    e.Cancel = false;
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
示例#4
0
        private void editControl1_UpdateContextToolTip(object sender, Syncfusion.Windows.Forms.Edit.UpdateTooltipEventArgs e)
        {
            if (e.Text == string.Empty)
            {
                Point pointVirtual = editControl1.PointToVirtualPosition(new Point(e.X, e.Y));

                if (pointVirtual.Y > 0)
                {
                    // Get the current line
                    ILexemLine line = editControl1.GetLine(pointVirtual.Y);

                    if (line != null)
                    {
                        // Get tokens from the current line
                        ILexem lexem = line.FindLexemByColumn(pointVirtual.X);

                        if (lexem != null)
                        {
                            IConfigLexem configLexem = lexem.Config as IConfigLexem;
                            string       formatName  = configLexem.Format.Name;
                            e.Text = "This is a " + formatName + " : " + lexem.Text;
                        }
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        /// Gets context tooltip.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editControl1_UpdateContextToolTip(object sender, Syncfusion.Windows.Forms.Edit.UpdateTooltipEventArgs e)
        {
            // If the text is already specified, than we should not change it. This is needed to display default tooltip for the collapsed region.
            if (e.Text != string.Empty)
            {
                return;
            }

            // Convert position of the mouse cursor to the position in text.
            Point virt = editControl1.PointToVirtualPosition(new Point(e.X, e.Y), true);

            // If there is no text in tat position, tan exit.
            if (virt.IsEmpty == true)
            {
                return;
            }

            ILexemLine line = editControl1.GetLine(virt.Y);

            if (line != null)
            {
                // Get lexem under cursor.
                ILexem lexem = line.FindLexemByColumn(virt.X);

                if (lexem != null)
                {
                    // Set text of the tooltip.
                    e.Text = GetLexemInfo(lexem) + "\n";

                    // Get stack of the lexem.
                    ConfigStack stack = line.GetStackByColumn(virt.X);

                    if (stack != null)
                    {
                        e.Text += "Stack before parsing lexem:\n";

                        while (stack.Count > 0)
                        {
                            IStackData stackItem =
                                ( IStackData )stack.Pop();

                            if (stackItem.Lexem != null)
                            {
                                e.Text += "-- " + GetLexemInfo(stackItem.Lexem) + "\n";
                            }
                        }

                        e.Text += "\n";
                    }

                    // Add description if present.
                    if (m_MethodComments.Contains(lexem.Config.ID))
                    {
                        e.Text += "Lexem contains description:\n";
                        e.Text += m_MethodComments[lexem.Config.ID];
                    }
                }
            }
        }
示例#6
0
 public ILexem Create(ILexem prev, string str)
 {
     if (prev is BinOperator || prev == null)
     {
         return(new LModul());
     }
     return(new RModul());
 }
示例#7
0
 public ILexem Create(ILexem prev, string str)
 {
     if (prev is ILBracket || prev is null)
     {
         return(new UnMinus());
     }
     return(new BinMinus());
 }
示例#8
0
        /// <summary>
        /// Формирует постфиксную запись выражения
        /// </summary>
        /// <param name="expression">Лексемы в инфиксной форме записи</param>
        /// <returns>Возвращает лексемы записанные в постфиксной записи</returns>
        public static List <ILexem> Postfix(List <ILexem> expression)
        {
            List <ILexem>  postfix = new List <ILexem>();
            Stack <ILexem> opStack = new Stack <ILexem>();

            foreach (var element in expression)
            {
                if (element.Type == LexemType.Identifier || element.Type == LexemType.Constant)
                {
                    postfix.Add(element);
                }
                else
                {
                    switch (element.Literal)
                    {
                    case "(":
                    {
                        opStack.Push(element);
                        break;
                    }

                    case ")":
                    {
                        var top = opStack.Pop();
                        while (top.Literal != "(")
                        {
                            postfix.Add(top);
                            top = opStack.Pop();
                        }
                        break;
                    }

                    default:
                    {
                        while (opStack.Count > 0)
                        {
                            ILexem lex = opStack.Peek();
                            if (Symbols[lex.Literal].Priority >= element.Priority)
                            {
                                postfix.Add(opStack.Pop());
                            }
                            else
                            {
                                break;
                            }
                        }
                        opStack.Push(element);
                        break;
                    }
                    }
                }
            }
            while (opStack.Count > 0)
            {
                postfix.Add(opStack.Pop());
            }
            return(postfix);
        }
示例#9
0
        /// <summary>
        /// Gets lexeme info.
        /// </summary>
        /// <param name="lexem">Lexem.</param>
        /// <returns>Lexem info text.</returns>
        private string GetLexemInfo(ILexem lexem)
        {
            // Get configuration path of the lexem under cursor.
            // Example: Property1 will have path like "this->.->Property1".
            string       confPath = lexem.Config.BeginBlock;
            IConfigLexem conf     = lexem.Config.ParentConfig;

            while (conf != null && !(conf is IConfigLanguage))
            {
                confPath = conf.BeginBlock + "->" + confPath;
                conf     = conf.ParentConfig;
            }

            return(string.Format("Text: \"{0}\"; ConfigPath: \"{1}\"; FormatName: {2}", lexem.Text, confPath, lexem.Config.Format.Name));
        }
示例#10
0
        // Returns the last index of the context choice character - '.' in the current line
        private int GetContextChoiceCharIndex(ILexemLine line)
        {
            int lastPos = -1;

            for (int i = 0; i < line.LineLexems.Count; i++)
            {
                ILexem lex = line.LineLexems[i] as ILexem;

                if (lex.Text == ".")
                {
                    lastPos = i;
                }
            }

            return(lastPos);
        }
示例#11
0
        /// <summary>
        /// Looks for the first lexeme on the left with DropContextChoiceList set to true in config
        /// </summary>
        /// <returns></returns>
        private ILexem FindDropper()
        {
            ILexemLine line = editControl1.CurrentLineInstance;

            if (line == null)
            {
                return(null);
            }

            ILexem lexem = line.FindLexemByColumn(editControl1.CurrentColumn);

            if (lexem == null)
            {
                // If we are in the virtual space in the line.
                if (editControl1.CurrentColumn > 1)
                {
                    lexem = line.FindLexemByColumn(line.LineLength);
                }

                if (lexem == null)
                {
                    return(null);
                }
            }

            // If current lexem is dropper itself
            if (lexem.Config.DropContextChoiceList)
            {
                return(lexem);
            }

            int index = line.LineLexems.IndexOf(lexem);

            while (index > 0 && !lexem.Config.DropContextChoiceList)
            {
                lexem = line.LineLexems[--index] as ILexem;
            }

            if (index <= 0)
            {
                lexem = null;
            }

            return(lexem);
        }
示例#12
0
 ILexem ILexemFabric.Create(ILexem prev, string str)
 {
     return(new Tan());
 }
示例#13
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new CustomLogarithm());
 }
示例#14
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new ModulFunction());
 }
示例#15
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new Sin());
 }
示例#16
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new LRoundBracket());
 }
示例#17
0
 private bool IsQuote(ILexem lexem)
 {
     return(lexem is SeparatorToken sepToken && sepToken.Value == SeparatorToken.Separator.Quote);
 }
示例#18
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new Number(double.Parse(str)));
 }
示例#19
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new NaturalLogarithm());
 }
示例#20
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new Multiply());
 }
示例#21
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new EConst());
 }
示例#22
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new Comma());
 }
示例#23
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new Divide());
 }
示例#24
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new Power());
 }
示例#25
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new Factorial());
 }
示例#26
0
 public ILexem Create(ILexem prev, string str)
 {
     return(new Exponent());
 }