Exemple #1
0
        private PListLexem ReadLineComment()
        {
            CharPosition  startPos = new CharPosition(charPosition);
            StringBuilder b        = new StringBuilder();

            b.Append(Char).Append(Next);
            MoveNext();
            MoveNext();
            while (!IsEOF())
            {
                if (Char == '\n')
                {
                    MoveNext();
                    break;
                }
                b.Append(Char);
                MoveNext();
            }
            return(new PListLexem(b.ToString(), LexemType.Comment, startPos));
        }
Exemple #2
0
        private PListLexem ReadQuotedString(char openChar)
        {
            CharPosition  startPos = new CharPosition(charPosition);
            StringBuilder b        = new StringBuilder();

            MoveNext();
            bool closed = false;

            while (!IsEOF())
            {
                if (Char == '\\')
                {
                    if (HasNext())
                    {
                        if (Next == openChar)
                        {
                            b.Append(Next);
                            MoveNext();
                            MoveNext();
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                else if (Char == openChar)
                {
                    MoveNext();
                    closed = true;
                    break;
                }
                b.Append(Char);
                MoveNext();
            }
            if (!closed)
            {
                throw new Exception(String.Format("Unclosed string starting at {0}", startPos));
            }
            return(new PListLexem(b.ToString(), LexemType.String, startPos));
        }
Exemple #3
0
        private PListLexem ReadString()
        {
            CharPosition  startPos = new CharPosition(charPosition);
            StringBuilder b        = new StringBuilder();
            bool          closed   = false;

            while (!IsEOF())
            {
                if (delimiters.Contains(Char))
                {
                    closed = true;
                    break;
                }
                b.Append(Char);
                MoveNext();
            }
            if (!closed)
            {
                throw new Exception(String.Format("Unclosed string starting at {0}", startPos));
            }
            string stringVal = b.ToString().TrimEnd();

            return(new PListLexem(stringVal, LexemType.String, startPos));
        }
Exemple #4
0
 public PListReader(string str)
 {
     this.str     = str;
     pos          = 0;
     charPosition = new CharPosition(1, 1);
 }
Exemple #5
0
 public CharPosition(CharPosition pos)
 {
     this.Line         = pos.Line;
     this.LinePosition = pos.LinePosition;
 }
Exemple #6
0
 public PListLexem(string val, LexemType type, CharPosition Position)
 {
     this.Value    = val;
     this.Type     = type;
     this.Position = Position;
 }