Exemple #1
0
        private IEnumerable <CharPos> ParseText(ITextChars tc)
        {
            while (!tc.EndOfLine)
            {
                if (tc.Char() == '\'')
                {
                    // single line comment
                    tc.SkipRemainder();
                }
                else if (tc.Char() == '"')
                {
                    this.status = stString;
                    tc.Next();
                    this.ParseString(tc);
                }
                else if (language.BraceList.IndexOf(tc.Char()) >= 0)
                {
                    yield return(new CharPos(tc.Char(), tc.AbsolutePosition));

                    tc.Next();
                }
                else
                {
                    tc.Next();
                }
            }
        }
Exemple #2
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() == '@' && tc.NChar() == '"')
         {
             this.status = stMultiLineString;
             tc.Skip(2);
             this.ParseMultiLineString(tc);
         }
         else if (tc.Char() == '$' && tc.NChar() == '"')
         {
             // Roslyn interpolated string
             this.parsingExpression = false;
             this.status            = stIString;
             tc.Skip(2);
             return(this.ParseInterpolatedString(tc, ref pos));
         }
         else if (tc.Char() == '$' && tc.NChar() == '@' && tc.NNChar() == '"')
         {
             this.status = stMultiLineString;
             tc.Skip(3);
             this.ParseMultiLineString(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, EncodedState());
             tc.Next();
             return(true);
         }
         else
         {
             tc.Next();
         }
     }
     return(false);
 }
Exemple #3
0
        private IEnumerable <CharPos> ParseText(ITextChars tc)
        {
            while (!tc.EndOfLine)
            {
                if (tc.Char() == '#')
                {
                    tc.SkipRemainder();
                }
                else if ((tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"') ||
                         (tc.Char() == '\'' && tc.NChar() == '\'' && tc.NNChar() == '\''))
                {
                    this.status    = stMultiLineString;
                    this.quoteChar = tc.Char();
                    tc.Skip(3);
                    this.ParseMultiLineString(tc);
                }
                else if (tc.Char() == '\'' || tc.Char() == '"')
                {
                    this.status    = stString;
                    this.quoteChar = tc.Char();
                    tc.Next();
                    this.ParseString(tc);
                }
                else if (lang.BraceList.IndexOf(tc.Char()) >= 0)
                {
                    yield return(new CharPos(tc.Char(), tc.AbsolutePosition));

                    tc.Next();
                }
                else
                {
                    tc.Next();
                }
            }
        }
Exemple #4
0
        private bool Parse(ITextChars tc, ref CharPos pos)
        {
            while (!tc.AtEnd)
            {
                // Comment.
                if (tc.Char() == '#')
                {
                    tc.SkipRemainder();
                }

                // String.
                else if (tc.Char() == '"')
                {
                    tc.Next();

                    this.status = State.MultiLineString;
                    this.String(tc);

                    continue;
                }

                // Braces.
                else if (this.BraceList.IndexOf(tc.Char()) >= 0)
                {
                    pos = new CharPos(tc.Char(), tc.AbsolutePosition);
                    tc.Next();
                    return(true);
                }

                // Code.
                tc.Next();
            }
            return(false);
        }
Exemple #5
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() == '\'')
                {
                    this.status = stString;
                    tc.Next();
                    this.ParseString(tc);
                }
                else if (lang.BraceList.IndexOf(tc.Char()) >= 0)
                {
                    yield return(new CharPos(tc.Char(), tc.AbsolutePosition));

                    tc.Next();
                }
                else
                {
                    tc.Next();
                }
            }
        }
 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() == '\'')
         {
             this.status = stString;
             tc.Next();
             this.ParseString(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);
 }
Exemple #7
0
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     while (!tc.AtEnd)
     {
         if (tc.Char() == '!')
         {
             // single line comment
             tc.SkipRemainder();
         }
         else if (tc.Char() == '\'')
         {
             this.status = stStringSingle;
             tc.Next();
             ParseStringSingle(tc);
         }
         else if (tc.Char() == '"')
         {
             this.status = stStringDouble;
             tc.Next();
             ParseStringDouble(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);
 }
Exemple #8
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);
 }
        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();
                }
            }
        }
Exemple #10
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() == '"')
         {
             this.status = stString;
             tc.Next();
             this.ParseString(tc);
         }
         else if (Char.IsDigit(tc.Char()) && tc.NChar() == '\'')
         {
             // this is a C++ 14 digit separator, such as 1'000'000
             tc.Skip(2);
         }
         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);
 }
Exemple #11
0
 private IEnumerable<CharPos> ParseText(ITextChars tc)
 {
     while ( !tc.EndOfLine ) {
     if ( tc.Char() == '\'' ) {
       // single line comment
       tc.SkipRemainder();
     } else if ( tc.Char() == '"' ) {
       this.status = stString;
       tc.Next();
       this.ParseString(tc);
     } else if ( braceList.IndexOf(tc.Char()) >= 0 ) {
       yield return new CharPos(tc.Char(), tc.AbsolutePosition);
       tc.Next();
     } else {
       tc.Next();
     }
       }
 }
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     pos = CharPos.Empty;
     while (!tc.AtEnd)
     {
         if (tc.Char() == '/' && tc.NChar() == '*')
         {
             this.state = stComment;
             tc.Skip(2);
             ParseComment(tc);
         }
         else if (tc.Char() == '/' && tc.NChar() == '/')
         {
             // CSS doesn't really support single-line comments,
             // but SASS does, and it doesn't harm too
             // much to implement it as a single thing
             tc.SkipRemainder();
         }
         else if (tc.Char() == '"')
         {
             this.state = stDoubleQuotedString;
             tc.Next();
             ParseDString(tc);
         }
         else if (tc.Char() == '\'')
         {
             this.state = stSingleQuotedString;
             tc.Next();
             ParseString(tc);
         }
         else if (this.BraceList.Contains(tc.Char()))
         {
             pos = new CharPos(tc.Char(), tc.AbsolutePosition);
             tc.Next();
             return(true);
         }
         else
         {
             tc.Next();
         }
     }
     return(false);
 }
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     while ( !tc.EndOfLine ) {
     if ( tc.Char() == '\'' ) {
       // single line comment
       tc.SkipRemainder();
     } else if ( tc.Char() == '"' ) {
       this.status = stString;
       tc.Next();
       this.ParseString(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;
 }
Exemple #14
0
        private IEnumerable <CharPos> ParseText(ITextChars tc)
        {
            while (!tc.EndOfLine)
            {
                if (tc.Char() == '/' && tc.NChar() == '*')
                {
                    this.state = stComment;
                    tc.Skip(2);
                    ParseComment(tc);
                }
                else if (tc.Char() == '/' && tc.NChar() == '/')
                {
                    // CSS doesn't really support single-line comments,
                    // but SASS does, and it doesn't harm too
                    // much to implement it as a single thing
                    tc.SkipRemainder();
                }
                else if (tc.Char() == '"')
                {
                    this.state = stDoubleQuotedString;
                    tc.Next();
                    ParseDString(tc);
                }
                else if (tc.Char() == '\'')
                {
                    this.state = stSingleQuotedString;
                    tc.Next();
                    ParseString(tc);
                }
                else if (lang.BraceList.Contains(tc.Char()))
                {
                    yield return(new CharPos(tc.Char(), tc.AbsolutePosition));

                    tc.Next();
                }
                else
                {
                    tc.Next();
                }
            }
        }
Exemple #15
0
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     while (!tc.EndOfLine)
     {
         if (tc.Char() == '/' && tc.NChar() == '*')
         {
             tc.Skip(2);
             status = stMultiLineComment;
             ParseMultilineComment(tc);
         }
         else if (tc.Char() == '/' && tc.NChar() == '/')
         {
             tc.SkipRemainder();
         }
         else if (tc.Char() == '\'')
         {
             status = stString;
             tc.Next();
             ParseCharLiteral(tc);
         }
         else if (tc.Char() == '"')
         {
             status = stString;
             tc.Next();
             ParseString(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);
 }
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     while (!tc.AtEnd)
     {
         if (tc.Char() == '#')
         {
             tc.SkipRemainder();
         }
         else if ((tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"') ||
                  (tc.Char() == '\'' && tc.NChar() == '\'' && tc.NNChar() == '\''))
         {
             this.status    = stMultiLineString;
             this.quoteChar = tc.Char();
             tc.Skip(3);
             this.ParseMultiLineString(tc);
         }
         else if (tc.Char() == '\'' || tc.Char() == '"')
         {
             this.status    = stString;
             this.quoteChar = tc.Char();
             tc.Next();
             this.ParseString(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);
 }
 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() == '@' && tc.NChar() == '"' ) {
       this.status = stString;
       this.multiLine = true;
       tc.Skip(2);
       this.ParseMultiLineString(tc);
     } else if ( tc.Char() == '$' && tc.NChar() == '"' ) {
       // Roslyn interpolated string
       this.parsingExpression = false;
       this.status = stIString;
       tc.Skip(2);
       return this.ParseInterpolatedString(tc, ref pos);
     } else if ( tc.Char() == '$' && tc.NChar() == '@' && tc.NNChar() == '"' ) {
       this.status = stIString;
       this.multiLine = true;
       this.parsingExpression = false;
       tc.Skip(3);
       return this.ParseInterpolatedString(tc, ref pos);
     } 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, EncodedState());
       tc.Next();
       return true;
     } else {
       tc.Next();
     }
       }
       return false;
 }
 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() == '\'' ) {
       this.status = stString;
       tc.Next();
       this.ParseString(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;
 }
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     while ( !tc.EndOfLine ) {
     // multi-line comment
     if ( tc.Char() == '(' && tc.NChar() == '*' && tc.NNChar() != ')') {
       this.status = stMultiLineComment;
       tc.Skip(2);
       this.ParseMultiLineComment(tc);
     } else if ( tc.Char() == '/' && tc.NChar() == '/' ) {
       tc.SkipRemainder();
     } else if ( tc.Char() == '@' && tc.NChar() == '"' ) {
       this.status = stVerbatimString;
       tc.Skip(2);
       this.ParseVerbatimString(tc);
     } else if ( tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"' ) {
       this.status = stTripleQuotedString;
       tc.Skip(3);
       this.ParseTripleQuotedString(tc);
     } else if ( tc.Char() == '"' ) {
       this.status = stString;
       tc.Next();
       this.ParseString(tc);
     } else if ( tc.Char() == '<' && tc.NChar() == '\'') {
       // this is just a generic parameter, so skip it already
       tc.Skip(2);
     } else if ( Char.IsLetterOrDigit(tc.Char()) && tc.NChar() == '\'' ) {
       // identifier like c'
       tc.Skip(2);
     } else if ( tc.Char() == '\'' ) {
       this.status = stChar;
       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;
 }
 public bool Extract(ITextChars text, ref CharPos pos)
 {
     text.SkipRemainder();
       return false;
 }
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     while (!tc.AtEnd)
     {
         // multi-line comment
         if (tc.Char() == '(' && tc.NChar() == '*' && tc.NNChar() != ')')
         {
             this.status = stMultiLineComment;
             tc.Skip(2);
             this.ParseMultiLineComment(tc);
         }
         else if (tc.Char() == '/' && tc.NChar() == '/')
         {
             tc.SkipRemainder();
         }
         else if (tc.Char() == '@' && tc.NChar() == '"')
         {
             this.status = stVerbatimString;
             tc.Skip(2);
             this.ParseVerbatimString(tc);
         }
         else if (tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"')
         {
             this.status = stTripleQuotedString;
             tc.Skip(3);
             this.ParseTripleQuotedString(tc);
         }
         else if (tc.Char() == '"')
         {
             this.status = stString;
             tc.Next();
             this.ParseString(tc);
         }
         else if (tc.Char() == '<' && tc.NChar() == '\'')
         {
             // this is just a generic parameter, so skip it already
             tc.Skip(2);
         }
         else if (Char.IsLetterOrDigit(tc.Char()) && tc.NChar() == '\'')
         {
             // identifier like c'
             tc.Skip(2);
         }
         else if (tc.Char() == '\'')
         {
             this.status = stChar;
             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);
 }
 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;
 }
Exemple #23
0
 private IEnumerable<CharPos> ParseText(ITextChars tc)
 {
     while ( !tc.EndOfLine ) {
     if ( tc.Char() == '/' && tc.NChar() == '*' ) {
       this.state = stComment;
       tc.Skip(2);
       ParseComment(tc);
     } else if ( tc.Char() == '/' && tc.NChar() == '/' ) {
       // CSS doesn't really support single-line comments,
       // but SASS does, and it doesn't harm too
       // much to implement it as a single thing
       tc.SkipRemainder();
     } else if ( tc.Char() == '"' ) {
       this.state = stDoubleQuotedString;
       tc.Next();
       ParseDString(tc);
     } else if ( tc.Char() == '\'' ) {
       this.state = stSingleQuotedString;
       tc.Next();
       ParseString(tc);
     } else if ( braceList.Contains(tc.Char()) ) {
       yield return new CharPos(tc.Char(), tc.AbsolutePosition);
       tc.Next();
     } else {
       tc.Next();
     }
       }
 }
Exemple #24
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() == '"' ) {
       this.status = stString;
       tc.Next();
       this.ParseString(tc);
     } else if ( Char.IsDigit(tc.Char()) && tc.NChar() == '\'' ) {
       // this is a C++ 14 digit separator, such as 1'000'000
       tc.Skip(2);
     } 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;
 }
Exemple #25
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.SkipRemainder();
     } else if ( tc.Char() == '@' && tc.NChar() == '\'' ) {
       this.status = stHereString;
       tc.Skip(2);
       this.ParseHereString(tc);
     } else if ( tc.Char() == '@' && tc.NChar() == '"' ) {
       this.status = stHereExpandableString;
       tc.Skip(2);
       this.ParseHereExpandableString(tc);
     } else if ( tc.Char() == '"' ) {
       this.status = stString;
       tc.Next();
       this.ParseExpandableString(tc);
     } else if ( tc.Char() == '\'' ) {
       this.status = stString;
       tc.Next();
       this.ParseString(tc);
     } else if ( braceList.IndexOf(tc.Char()) >= 0 ) {
       yield return new CharPos(tc.Char(), tc.AbsolutePosition);
       tc.Next();
     } else {
       tc.Next();
     }
       }
 }
 private IEnumerable<CharPos> ParseText(ITextChars tc)
 {
     while ( !tc.EndOfLine ) {
     if ( tc.Char() == '#' ) {
       tc.SkipRemainder();
     } else if ( (tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"')
          || (tc.Char() == '\'' && tc.NChar() == '\'' && tc.NNChar() == '\'') ) {
       this.status = stMultiLineString;
       this.quoteChar = tc.Char();
       tc.Skip(3);
       this.ParseMultiLineString(tc);
     } else if ( tc.Char() == '\'' || tc.Char() == '"' ) {
       this.status = stString;
       this.quoteChar = tc.Char();
       tc.Next();
       this.ParseString(tc);
     } else if ( braceList.IndexOf(tc.Char()) >= 0 ) {
       yield return new CharPos(tc.Char(), tc.AbsolutePosition);
       tc.Next();
     } else {
       tc.Next();
     }
       }
 }
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     pos = CharPos.Empty;
       while ( !tc.EndOfLine ) {
     if ( tc.Char() == '/' && tc.NChar() == '*' ) {
       this.state = stComment;
       tc.Skip(2);
       ParseComment(tc);
     } else if ( tc.Char() == '/' && tc.NChar() == '/' ) {
       // CSS doesn't really support single-line comments,
       // but SASS does, and it doesn't harm too
       // much to implement it as a single thing
       tc.SkipRemainder();
     } else if ( tc.Char() == '"' ) {
       this.state = stDoubleQuotedString;
       tc.Next();
       ParseDString(tc);
     } else if ( tc.Char() == '\'' ) {
       this.state = stSingleQuotedString;
       tc.Next();
       ParseString(tc);
     } else if ( this.BraceList.Contains(tc.Char()) ) {
       pos = new CharPos(tc.Char(), tc.AbsolutePosition);
       tc.Next();
       return true;
     } else {
       tc.Next();
     }
       }
       return false;
 }
 public bool Extract(ITextChars text, ref CharPos pos)
 {
     text.SkipRemainder();
     return(false);
 }
 private bool ParseText(ITextChars tc, ref CharPos pos)
 {
     while ( !tc.EndOfLine ) {
     if ( tc.Char() == '#' ) {
       tc.SkipRemainder();
     } else if ( (tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"')
          || (tc.Char() == '\'' && tc.NChar() == '\'' && tc.NNChar() == '\'') ) {
       this.status = stMultiLineString;
       this.quoteChar = tc.Char();
       tc.Skip(3);
       this.ParseMultiLineString(tc);
     } else if ( tc.Char() == '\'' || tc.Char() == '"' ) {
       this.status = stString;
       this.quoteChar = tc.Char();
       tc.Next();
       this.ParseString(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;
 }
Exemple #30
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() == '@' && tc.NChar() == '"')
                {
                    this.status = stVerbatimString;
                    tc.Skip(2);
                    this.ParseVerbatimString(tc);
                }
                else if (tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"')
                {
                    this.status = stTripleQuotedString;
                    tc.Skip(3);
                    this.ParseTripleQuotedString(tc);
                }
                else if (tc.Char() == '"')
                {
                    this.status = stString;
                    tc.Next();
                    this.ParseString(tc);
                }
                else if (tc.Char() == '<' && tc.NChar() == '\'')
                {
                    // this is just a generic parameter, so skip it already
                    tc.Skip(2);
                }
                else if (Char.IsLetterOrDigit(tc.Char()) && tc.NChar() == '\'')
                {
                    // identifier like c'
                    tc.Skip(2);
                }
                else if (tc.Char() == '\'')
                {
                    this.status = stChar;
                    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();
                }
            }
        }