using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; namespace Rokojori { public class LexerEvent { string _type; int _offset; int _length; string _match; public string match => _match; public LexerEvent( string type, int offset, int length ) { set( type, offset, length ); } public string type { get { return _type; } } public int offset { get { return _offset; } } public int length { get { return _length; } } public bool isError { get { return this.length == -1; } } public bool isDone { get { return this.length == -2; } } public void set( string type, int offset, int length ) { this._type = type; this._offset = offset; this._length = length; } public LexerEvent Copy() { return new LexerEvent( _type, _offset, _length ); } public int end { get { return this._offset + _length; } } public override string ToString() { return "Token{ '" + type + "' (" + offset + "-" + end + ") }"; } public void GrabMatch( string source ) { if ( _length < 0 ) { return; } _match = source.Substring( offset, length ); } } }