public static int Compare(SourceLocation x, SourceLocation y) { if (x.Position < y.Position) return -1; if (x.Position == y.Position) return 0; return 1; }
public SourceSpan(SourceLocation start, int length) { Start = start; Length = length; }
public RuntimeException(String message, Exception inner, SourceLocation location) : base(message, inner) { Location = location; }
public override void OnSetSourceLocation(SourceLocation location) { while (_braces.Count > 0 && _braces.Peek().Location.Position >= location.Position) _braces.Pop(); }
public SourceStream(String text, int offset, int tabWidth) { _text = text; _tabWidth = tabWidth; _position = offset; TokenStart = new SourceLocation(); }
private Token CreateSpecialToken(Terminal term, SourceLocation location) { return new Token(term, location, string.Empty, null); }
public void ResetSourceLocation(SourceLocation tokenStart, int position) { _currentInput = null; InputStack.Clear(); _scanner.SetSourceLocation(tokenStart, position); }
//Switches Scanner into preview mode public void BeginPreview() { _inPreview = true; _savedTokenStart = _source.TokenStart; _savedPosition = _source.Position; _previewTokens.Clear(); }
//TODO: this is messed up, need to fix all code related to TokenStart and position and resetting it // problem: tokenStart is the position of "last" (previous) token, while position parameter is a position where next token will start public void SetSourceLocation(SourceLocation tokenStart, int position) { foreach (var filter in _data.TokenFilters) filter.OnSetSourceLocation(tokenStart); _source.TokenStart = tokenStart; _source.Position = position; }