NextChar() public method

public NextChar ( ) : char
return char
コード例 #1
0
        private void ScanDefault(LineProgress p)
        {
            while (!p.EndOfLine)
            {
                if (p.Char() == '/' && p.NextChar() == '/' && p.NextNextChar() == '/') // doc comment.
                {
                    p.Advance(3);
                    p.State = State.DocComment;
                    ScanDocComment(p);
                }
                else if (p.Char() == '/' && p.NextChar() == '/') // single line comment
                {
                    p.Advance(2);
                    p.StartNaturalText();
                    p.AdvanceToEndOfLine();
                    p.EndNaturalText();

                    p.State = State.Default;
                    return;
                }
                else if (p.Char() == '/' && p.NextChar() == '*') // multi-line comment
                {
                    p.Advance(2);
                    p.State = State.MultiLineComment;
                    ScanMultiLineComment(p);
                }
                else if (p.Char() == '@' && p.NextChar() == '"') // multi-line string
                {
                    p.Advance(2);
                    p.State = State.MultiLineString;
                    ScanMultiLineString(p);
                }
                else if (p.Char() == '"') // single-line string
                {
                    p.Advance(1);
                    p.State = State.String;
                    ScanString(p);
                }
                else if (p.Char() == '\'') // character literal
                {
                    p.Advance(1);
                    p.State = State.Character;
                    ScanCharacter(p);
                }
                else
                {
                    p.Advance();
                }
            }
        }
コード例 #2
0
        private void ScanMultiLineString(LineProgress p)
        {
            p.StartNaturalText();

            while (!p.EndOfLine)
            {
                if (p.Char() == '"' && p.NextChar() == '"') // "" is allowed within multiline string.
                {
                    p.Advance(2);
                }
                else if (p.Char() == '"') // end of multi-line string
                {
                    p.EndNaturalText();

                    p.Advance();
                    p.State = State.Default;
                    return;
                }
                else
                {
                    p.Advance();
                }
            }

            // End of line.  Emit as human readable, but remain in MultiLineString state.
            p.EndNaturalText();
            Debug.Assert(p.State == State.MultiLineString);
        }
コード例 #3
0
        private void ScanMultiLineComment(LineProgress p)
        {
            p.StartNaturalText();

            while (!p.EndOfLine)
            {
                if (p.Char() == '*' && p.NextChar() == '/') // close comment
                {
                    p.EndNaturalText();
                    p.Advance(2);
                    p.State = State.Default;

                    return; // done with multi-line comment.
                }
                else
                {
                    p.Advance();
                }
            }

            // End of line.  Emit as human readable, but remain in MultiLineComment state.
            p.EndNaturalText();
            Debug.Assert(p.State == State.MultiLineComment);
        }