public override Token ReadToken(TextBuffer textBuffer)
        {
            Match match = GetMatch(textBuffer);

            if (match.Groups[2].Value == ")" && StartsWithNonWhitespaceRegex.IsMatch(textBuffer.Remainder))
                throw new InvalidWordException(textBuffer, "Comment not properly ended.", false);

            return new ParanEndedStringToken(match.Groups[1].Value, match.Groups[2].Value == ")");
        }
        private static string buildMessage(TextBuffer textBuffer, string errorDescription, bool undoLastRead)
        {
            if (undoLastRead)
                textBuffer.UndoRead();

            WordToken wordToken = TokenReader.ReadWordToken(textBuffer);

            int arrowsIndex = textBuffer.PreviousIndex + textBuffer.LastRead.Length - wordToken.Name.Length;
            string arrowsLine = Regex.Replace(textBuffer.Text.Substring(0, arrowsIndex), @"\S", " ", RegexOptions.Singleline);

            return string.Format("{0}\n{1}\n{2}", errorDescription, textBuffer.Text, arrowsLine + new string('^', wordToken.Name.Length));
        }
Ejemplo n.º 3
0
        protected Match GetMatch(TextBuffer textBuffer)
        {
            Match match = TokenRegex.Match(textBuffer.Remainder);

            if (match.Success)
            {
                textBuffer.MoveForward(match.Value.Length);
                return match;
            }
            else
                return null;
        }
        public override Token ReadToken(TextBuffer textBuffer)
        {
            string firstMatchGroup = GetFirstMatchGroup(textBuffer);

            if (firstMatchGroup != null)
            {
                int value;
                if (int.TryParse(firstMatchGroup, out value))
                    return new SignedIntegerToken(value);
                else
                    textBuffer.UndoRead();
            }

            return null;
        }
Ejemplo n.º 5
0
 public abstract Token ReadToken(TextBuffer textBuffer);
Ejemplo n.º 6
0
 public static SignedIntegerToken ReadSignedIntegerToken(TextBuffer textBuffer)
 {
     return (SignedIntegerToken)signedIntegerTokenReader.ReadToken(textBuffer);
 }
Ejemplo n.º 7
0
 public static WordToken ReadWordToken(TextBuffer textBuffer)
 {
     return (WordToken)wordTokenReader.ReadToken(textBuffer);
 }
Ejemplo n.º 8
0
 public static ParanEndedStringToken ReadParanEndedStringToken(TextBuffer textBuffer)
 {
     return (ParanEndedStringToken)paranEndedStringTokenReader.ReadToken(textBuffer);
 }
Ejemplo n.º 9
0
 public static QuoteEndedStringToken ReadQuoteEndedStringToken(TextBuffer textBuffer)
 {
     return (QuoteEndedStringToken)quoteEndedStringTokenReader.ReadToken(textBuffer);
 }
Ejemplo n.º 10
0
 public static EmptyLineToken ReadEmptyLineToken(TextBuffer textBuffer)
 {
     return (EmptyLineToken)emptyLineTokenReader.ReadToken(textBuffer);
 }
Ejemplo n.º 11
0
 public static LineCommentToken ReadLineCommentToken(TextBuffer textBuffer)
 {
     return (LineCommentToken)lineCommentTokenReader.ReadToken(textBuffer);
 }
Ejemplo n.º 12
0
 protected string GetFirstMatchGroup(TextBuffer textBuffer)
 {
     Match match = GetMatch(textBuffer);
     return (match != null ? match.Groups[1].Value : null);
 }
 public InvalidWordException(TextBuffer textBuffer)
     : this(textBuffer, true)
 {
 }
Ejemplo n.º 14
0
 public override Token ReadToken(TextBuffer textBuffer)
 {
     string firstMatchGroup = GetFirstMatchGroup(textBuffer);
     return (firstMatchGroup != null ? new WordToken(firstMatchGroup) : null);
 }
 public InvalidWordException(TextBuffer textBuffer, bool undoLastRead)
     : this(textBuffer, "Undefined word.", undoLastRead)
 {
 }
Ejemplo n.º 16
0
        public override Token ReadToken(TextBuffer textBuffer)
        {
            string firstMatchGroup = GetFirstMatchGroup(textBuffer);

            return(firstMatchGroup != null ? new WordToken(firstMatchGroup) : null);
        }
 public InvalidWordException(TextBuffer textBuffer, string errorDescription)
     : this(textBuffer, errorDescription, true)
 {
 }
 public InvalidWordException(TextBuffer textBuffer, string errorDescription, bool undoLastRead)
     : base(buildMessage(textBuffer, errorDescription, undoLastRead))
 {
 }
 public override Token ReadToken(TextBuffer textBuffer)
 {
     return new QuoteEndedStringToken(GetFirstMatchGroup(textBuffer));
 }
 public override Token ReadToken(TextBuffer textBuffer)
 {
     return new LineCommentToken(GetFirstMatchGroup(textBuffer));
 }