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)); }
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; }
public abstract Token ReadToken(TextBuffer textBuffer);
public static SignedIntegerToken ReadSignedIntegerToken(TextBuffer textBuffer) { return (SignedIntegerToken)signedIntegerTokenReader.ReadToken(textBuffer); }
public static WordToken ReadWordToken(TextBuffer textBuffer) { return (WordToken)wordTokenReader.ReadToken(textBuffer); }
public static ParanEndedStringToken ReadParanEndedStringToken(TextBuffer textBuffer) { return (ParanEndedStringToken)paranEndedStringTokenReader.ReadToken(textBuffer); }
public static QuoteEndedStringToken ReadQuoteEndedStringToken(TextBuffer textBuffer) { return (QuoteEndedStringToken)quoteEndedStringTokenReader.ReadToken(textBuffer); }
public static EmptyLineToken ReadEmptyLineToken(TextBuffer textBuffer) { return (EmptyLineToken)emptyLineTokenReader.ReadToken(textBuffer); }
public static LineCommentToken ReadLineCommentToken(TextBuffer textBuffer) { return (LineCommentToken)lineCommentTokenReader.ReadToken(textBuffer); }
protected string GetFirstMatchGroup(TextBuffer textBuffer) { Match match = GetMatch(textBuffer); return (match != null ? match.Groups[1].Value : null); }
public InvalidWordException(TextBuffer textBuffer) : this(textBuffer, true) { }
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) { }
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)); }