コード例 #1
0
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     while (!tc.AtEnd)
     {
         // multi-line comment
         if (tc.Char() == '/' && tc.NChar() == '*')
         {
             this.status = stMultiLineComment;
             tc.Skip(2);
             this.ParseMultiLineComment(tc);
         }
         else if (tc.Char() == '/' && tc.NChar() == '/')
         {
             tc.SkipRemainder();
         }
         else if (tc.Char() == '/' && CheckPrevious(tc.PreviousToken()))
         {
             // probably a regular expression literal
             tc.Next();
             this.status = stRegex;
             this.ParseRegex(tc);
         }
         else if (tc.Char() == '"')
         {
             this.status = stString;
             tc.Next();
             this.ParseString(tc);
         }
         else if (tc.Char() == '\'')
         {
             this.status = stString;
             tc.Next();
             this.ParseCharLiteral(tc);
         }
         else if (tc.Char() == '`')
         {
             this.status = stIString;
             tc.Next();
             return(this.ParseInterpolatedString(tc, ref pos));
         }
         else if (this.BraceList.IndexOf(tc.Char()) >= 0)
         {
             pos = new CharPos(tc.Char(), tc.AbsolutePosition);
             tc.Next();
             return(true);
         }
         else
         {
             tc.Next();
         }
     }
     return(false);
 }
コード例 #2
0
        private IEnumerable <CharPos> ParseText(ITextChars tc)
        {
            while (!tc.EndOfLine)
            {
                // multi-line comment
                if (tc.Char() == '/' && tc.NChar() == '*')
                {
                    this.status = stMultiLineComment;
                    tc.Skip(2);
                    this.ParseMultiLineComment(tc);
                }
                else if (tc.Char() == '/' && tc.NChar() == '/')
                {
                    tc.SkipRemainder();
                }
                else if (tc.Char() == '/' && CheckPrevious(tc.PreviousToken()))
                {
                    // probably a regular expression literal
                    tc.Next();
                    this.status = stRegex;
                    this.ParseRegex(tc);
                }
                else if (tc.Char() == '"')
                {
                    this.status = stString;
                    tc.Next();
                    this.ParseString(tc);
                }
                else if (tc.Char() == '\'')
                {
                    this.status = stString;
                    tc.Next();
                    this.ParseCharLiteral(tc);
                }
                else if (lang.BraceList.IndexOf(tc.Char()) >= 0)
                {
                    yield return(new CharPos(tc.Char(), tc.AbsolutePosition));

                    tc.Next();
                }
                else
                {
                    tc.Next();
                }
            }
        }
コード例 #3
0
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     while ( !tc.EndOfLine ) {
     // multi-line comment
     if ( tc.Char() == '/' && tc.NChar() == '*' ) {
       this.status = stMultiLineComment;
       tc.Skip(2);
       this.ParseMultiLineComment(tc);
     } else if ( tc.Char() == '/' && tc.NChar() == '/' ) {
       tc.SkipRemainder();
     } else if ( tc.Char() == '/' && CheckPrevious(tc.PreviousToken()) ) {
       // probably a regular expression literal
       tc.Next();
       this.status = stRegex;
       this.ParseRegex(tc);
     } else if ( tc.Char() == '"' ) {
       this.status = stString;
       tc.Next();
       this.ParseString(tc);
     } else if ( tc.Char() == '\'' ) {
       this.status = stString;
       tc.Next();
       this.ParseCharLiteral(tc);
     } else if ( this.BraceList.IndexOf(tc.Char()) >= 0 ) {
       pos = new CharPos(tc.Char(), tc.AbsolutePosition);
       tc.Next();
       return true;
     } else {
       tc.Next();
     }
       }
       return false;
 }