Exemplo n.º 1
0
        public override void Init()
        {
            var whileE = new JWhileEleme();

            this.AddFather(whileE);
            this.ValidChar('(');
            whileE.Where        = new ValueEleme();
            whileE.Where.Father = this.NEleme;
            var vSpan = new ValueSpan(this.PBParser, whileE.Where);

            vSpan.Init();
            this.ValidChar(')');
            this.ValidChar('{');
            new JavaSciptSpan(this.PBParser, whileE).Init();
            this.ValidChar('}');
        }
Exemplo n.º 2
0
        private void AddOrReduce()
        {
            var fchar = this._Char;

            this.GetChar();
            if (this._Char != fchar)
            {
                this.Error();
            }
            this.ResetUpPoint();
            var line = new JLineEleme();

            this.AddFather(line);
            var valueSpan = new ValueSpan(this.PBParser, line);

            valueSpan.Init();
        }
Exemplo n.º 3
0
        private void NewClass()
        {
            var exists = this.ValidateNameExists(this._Tag);
            var newE   = new JNewEleme();

            if (exists == null)
            {
                this.Error(this._Tag + " 未定义");
            }
            newE.Name = exists.GetAliasName();
            this.AddFather(newE);
            this.SetUpPoint();
            this.GetChar();
            if (this._Char == ')')
            {
                return;
            }
            this.ResetUpPoint();

            if (newE.Arguments == null)
            {
                newE.Arguments = new List <ValueEleme>();
            }

Loop:
            var valueE = new ValueEleme();

            valueE.Father = this.NEleme;
            var valueS = new ValueSpan(this.PBParser, valueE);

            valueS.Init();
            newE.Arguments.Add(valueE);
            this.GetChar();
            switch (this._Char)
            {
            case ',':
                goto Loop;

            case ')':
                break;

            default:
                this.Error();
                break;
            }
        }
Exemplo n.º 4
0
        private void SetValue()
        {
            var varElem = new JPropertyEleme();

            varElem.IsSetValue          = true;
            varElem.Name                = this._Tag;
            varElem.Father              = this.NEleme;
            this.pVariableAttr.Property = varElem;

            var valueE = new ValueEleme();

            valueE.Father = this.NEleme;
            varElem.Value = valueE;
            var valueSpan = new ValueSpan(this.PBParser, valueE);

            valueSpan.Init();
        }
Exemplo n.º 5
0
        /// <summary>
        /// 索引
        /// </summary>
        private void Index()
        {
Start:
            this.SetUpPoint();
            this.GetChar();
            BEleme elem = null;

            if (Tools.StrStartChars.Contains(this._Char))
            {
                elem = new JConstEleme("\"" + this.GetString(this._Char) + "\"", EValueType.Const);
            }
            else if (char.IsNumber(this._Char))
            {
                elem = new JConstEleme(this.GetIntString(), EValueType.Const);
            }
            else
            {
                this.ResetUpPoint();
                elem        = new JValueEleme();
                elem.Father = this.NEleme;
                var valueS = new ValueSpan(this.PBParser, elem);
                valueS.Init();
            }
            this.GetChar();
            switch (this._Char)
            {
            case ',':
                goto Start;

            case ']':
                var jIndex = new JIndexEleme();
                jIndex.IndexEleme        = elem;
                elem.Father              = jIndex;
                this.pVariableAttr.Index = jIndex;
                jIndex.Father            = this.NEleme;
                this.End(EPType.Index, jIndex);
                break;

            default:
                this.Error();
                break;
            }
        }
Exemplo n.º 6
0
        private void Method()
        {
            this.SetUpPoint();
            this.GetChar();
            var varElem = new JMethodEleme();

            varElem.Name              = this._Tag;
            varElem.Father            = this.NEleme;
            this.pVariableAttr.Method = varElem;
            if (this._Char != ')')
            {
                this.ResetUpPoint();
Start:
                var noElem    = new NoEleme();
                noElem.Father = this.NEleme;
                var valueSpan = new ValueSpan(this.PBParser, noElem);
                valueSpan.Init();
                if (varElem.Arguments == null)
                {
                    varElem.Arguments = new List <BEleme>();
                }
                varElem.Arguments.Add(noElem.Childs[0]);

                this.GetChar();
                switch (this._Char)
                {
                case ',':
                    goto Start;

                case ')':
                    break;

                default:
                    this.Error();
                    break;
                }
            }
            this.End(EPType.Method, varElem);
        }
Exemplo n.º 7
0
        public override void Init()
        {
            if (string.IsNullOrEmpty(VarName))
            {
                this.GetTag();
                if (string.IsNullOrEmpty(this._Tag))
                {
                    this.Error("无法找到定义的变量名称");
                }
            }
            else
            {
                this._Tag = this.VarName;
            }

            this.ValidVar();
            var definition = new JDefinitionEleme();

            definition.SetPoint(this.PBParser.Point);
            definition.Name          = this._Tag;
            definition.OperationChar = this.OperationChar;
            this.AnalysisAnnotation(definition);
            BEleme vdef = null;

            if (string.IsNullOrEmpty(this.VarName))
            {
                vdef = this.ValidateNameExists(this._Tag, false);
            }
            else if (this.IsDef)
            {
                definition.PVariableType = Entity.EVariableType.SetValue;
            }

            if (vdef != null)
            {
                definition.PVariableType = Entity.EVariableType.SetValue;
                definition.Name          = definition.GetAliasName();
            }
            this.SetUpPoint();
            this.GetChar();
            if (this._Char == '=')
            {
                this.ResetUpPoint();
                this.ValidChar('=');
                this.AddFather(definition);
                var valueSpan = new ValueSpan(this.PBParser, definition);
                valueSpan.Init();
            }
            else if (this._Char == ',')
            {
                this.AddFather(definition, new JConstEleme("", Entity.EValueType.Undefined));
                this.AddFather(definition);
                this.ResetUpPoint();
            }
            else
            {
                if (this._Char != ';')
                {
                    this.ResetUpPoint();
                    this.GetChar(false);
                    if (this._Char != Tools.LineEndChar)
                    {
                        this.Error();
                    }
                }
                if (!(string.IsNullOrEmpty(VarName) || this.IsFollowUp))
                {
                    this.Error();
                }

                this.AddFather(definition, new JConstEleme("", Entity.EValueType.Undefined));
                this.AddFather(definition);
            }
            this.SetUpPoint();
            this.GetChar();
            if (this._Char == ',')
            {
                FollowUp();
            }
            else
            {
                this.ResetUpPoint();
            }
        }
Exemplo n.º 8
0
        public void For()
        {
            pFEleme   = new JForEleme();
            pForEleme = pFEleme as JForEleme;

            #region 定义参数
            this.SetUpPoint();
            this.GetChar();
            if (this._Char != ';')
            {
                this.ResetUpPoint();
                this.GetTag();
                var valueS = new VarSpan(this);
                if (this._Tag != "var")
                {
                    var exists = this.ValidateNameExists(this._Tag);
                    if (exists != null)
                    {
                        valueS.IsDef   = true;
                        valueS.VarName = exists.GetAliasName();
                    }
                    else
                    {
                        valueS.VarName = this._Tag;
                    }
                }
                valueS.Init();
            }

            #endregion

            #region Statement2
            this.SetUpPoint();
            this.GetChar();
            if (this._Char != ';')
            {
                this.ResetUpPoint();
                pForEleme.Statement2        = new ValueEleme();
                pForEleme.Statement2.Father = this.NEleme;
                var valueE = new ValueEleme();
                this.AddFather(pForEleme.Statement2, valueE);
                var valueS = new ValueSpan(this.PBParser, valueE);
                valueS.Init();
            }
            #endregion

            #region where
            this.SetUpPoint();
            this.GetChar();
            if (this._Char != ';')
            {
                this.ResetUpPoint();
                pForEleme.Where        = new ValueEleme();
                pForEleme.Where.Father = this.NEleme;
                var valueE = new ValueEleme();
                this.AddFather(pForEleme.Where, valueE);
                var valueS = new ValueSpan(this.PBParser, valueE);
                valueS.Init();
            }
            #endregion
        }