示例#1
0
 public CompressedState(Lexer lexer)
 {
     this._hereDocLabel = lexer._hereDocLabel;
     this._currentState = lexer.CurrentLexicalState;
     this._stateStack   = lexer.stateStack.ToArray();
     this._phpDoc       = lexer.DocBlock;
 }
示例#2
0
 void SaveDocComment(int extend)
 {
     if (backupDocBlock != null)
     {
         _phpDocs.AppendBlock(backupDocBlock, extend);
         backupDocBlock = null;
     }
 }
示例#3
0
        /// <summary>
        /// Get next token and store its actual position in the source unit.
        /// This implementation supports the functionality of zendlex, which skips empty nodes (open tag, comment, etc.).
        /// </summary>
        /// <returns>Next token.</returns>
        public int GetNextToken()
        {
            int docBlockExtend = -1;

            for (; ;)
            {
                Tokens token = (Tokens)_provider.GetNextToken();

                // origianl zendlex() functionality - skip open and close tags because they are not in the PHP grammar
                switch (token)
                {
                case Tokens.T_DOC_COMMENT:
                    SaveDocComment(docBlockExtend);
                    backupDocBlock = _provider.DocBlock;
                    docBlockExtend = TokenPosition.End;
                    continue;

                case Tokens.T_WHITESPACE:
                case Tokens.T_COMMENT:
                    docBlockExtend = TokenPosition.End;
                    continue;

                case Tokens.T_OPEN_TAG:
                    continue;

                case Tokens.T_CLOSE_TAG:
                    token = Tokens.T_SEMI;     /* implicit ; */
                    break;

                case Tokens.T_OPEN_TAG_WITH_ECHO:
                    token = Tokens.T_ECHO;
                    break;

                case Tokens.T_FN:
                    if (!HasFeatureSet(LanguageFeatures.Php74Set))
                    {
                        token = Tokens.T_STRING;
                    }
                    break;

                    //case Tokens.T_MATCH:
                    //    if (!HasFeatureSet(LanguageFeatures.Php80Set))
                    //    {
                    //        token = Tokens.T_STRING;
                    //    }
                    //    break;
                }
                SaveDocComment(docBlockExtend);

                return((int)token);
            }
        }
示例#4
0
        /// <summary>
        /// Finds DOC comment above given position, removes it from the internal list and returns its reference.
        /// </summary>
        public bool TryReleaseIndexedBlock(int index, out PHPDocBlock phpdoc)
        {
            if (index >= 0 && index < _doclist.Count)
            {
                var list = _doclist;
                phpdoc = list[index].PhpDoc;
                list.RemoveAt(index);
                this.UpdateSpan();

                //
                return(true);
            }

            //
            phpdoc = null;
            return(false);
        }
示例#5
0
        /// <summary>
        /// Get next token and store its actual position in the source unit.
        /// This implementation supports the functionality of zendlex, which skips empty nodes (open tag, comment, etc.).
        /// </summary>
        /// <returns>Next token.</returns>
        public int GetNextToken()
        {
            int docBlockExtend = -1;

            do
            {
                Tokens token = (Tokens)_provider.GetNextToken();

                // origianl zendlex() functionality - skip open and close tags because they are not in the PHP grammar
                switch (token)
                {
                case Tokens.T_DOC_COMMENT:
                    SaveDocComment(docBlockExtend);
                    backupDocBlock = _provider.DocBlock;
                    docBlockExtend = TokenPosition.End;
                    continue;

                case Tokens.T_WHITESPACE:
                case Tokens.T_COMMENT:
                    docBlockExtend = TokenPosition.End;
                    continue;

                case Tokens.T_OPEN_TAG:
                    continue;

                case Tokens.T_CLOSE_TAG:
                    token = Tokens.T_SEMI;     /* implicit ; */
                    break;

                case Tokens.T_OPEN_TAG_WITH_ECHO:
                    token = Tokens.T_ECHO;
                    break;
                }
                SaveDocComment(docBlockExtend);

                return((int)token);
            } while (true);
        }
示例#6
0
        /// <summary>
        /// Inserts DOC block into the list.
        /// </summary>
        public void AppendBlock(PHPDocBlock /*!*/ phpDoc, int endPosition)
        {
            Debug.Assert(phpDoc != null);
            Debug.Assert(endPosition >= phpDoc.Span.End);
            Debug.Assert(_doclist == null || _doclist.Count == 0 || _doclist.Last().Extent.Start < phpDoc.Span.Start, "Blocks have to be appended in order.");

            var docinfo = new DocInfo()
            {
                PhpDoc = phpDoc,
                Extent = Span.FromBounds(phpDoc.Span.Start, endPosition)
            };

            var list = _doclist;

            if (list == null)
            {
                _doclist = list = new List <DocInfo>(4);
            }

            list.Add(docinfo);

            _span = Span.FromBounds(list[0].Extent.Start, list.Last().Extent.End);
        }
示例#7
0
 public override void VisitPHPDocBlock(PHPDocBlock x)
 {
     // ignore
 }
示例#8
0
 virtual public void VisitPHPDocBlock(PHPDocBlock x)
 {
     // nothing
 }
示例#9
0
        /// <summary>
        /// Finds DOC comment inside given position, removes it from the internal list and returns its reference.
        /// </summary>
        public bool TryReleaseBlock(Span position, out PHPDocBlock phpdoc)
        {
            var index = FindFirstIn(_doclist, position);

            return(TryReleaseIndexedBlock(index, out phpdoc));
        }
示例#10
0
        /// <summary>
        /// Finds DOC comment above given position, removes it from the internal list and returns its reference.
        /// </summary>
        public bool TryReleaseBlock(int position, out PHPDocBlock phpdoc)
        {
            var index = this.FindIndex(position - 1);

            return(TryReleaseIndexedBlock(index, out phpdoc));
        }
示例#11
0
 void SetDocBlock() => DocBlock   = new PHPDocBlock(GetTokenString(intern: false), new Span(_charOffset, this.TokenLength));  // TokenPosition is not updated yet at this point
 void ResetDocBlock() => DocBlock = null;
示例#12
0
 void SetDocBlock() => DocBlock   = new PHPDocBlock(GetTokenString(intern: false), new Span(_charOffset, this.TokenLength));  // TokenPosition is not updated yet at this point