コード例 #1
0
        public bool ISIllegal(string Expression, bool ismess)
        {
            if (Expression.ToCharArray().Length >= 400)
            {
                MessageBox.Show("表达式太长");
                return(false);
            }
            string      ExpressionTemp = Expression + "#";
            WordAnalyse MyWords        = new WordAnalyse(ExpressionTemp);

            MyWords.GetResult();
            SyntaxAnalyse MySyntax = new SyntaxAnalyse();

            if (!MySyntax.Analyse(MyWords) && ismess)
            {
                MessageBox.Show("语法错误");
                return(false);
            }
            return(true);
        }
コード例 #2
0
        public bool Analyse(WordAnalyse pWords)
        {
            if (pWords.GetResult() == false)
            {
                return(false);
            }
            E(pWords);
            if (WordIndex < pWords.GetWordNum() - 1)
            {
                if (pWords.GetWord(WordIndex).CompareTo(')') == 0)
                {
                    MessageBox.Show("第" + (RoundBracketsL + 1) + "个右括号缺少左括号", "缺少左括号");
                }

                bResult   = true;
                WordIndex = 0;
                return(false);
            }
            bool tem = bResult;

            bResult   = true;
            WordIndex = 0;
            return(tem);
        }