2017-01-22 23:15:53 +00:00
|
|
|
import 'package:source_span/source_span.dart';
|
|
|
|
import 'token_type.dart';
|
|
|
|
|
|
|
|
class Token {
|
|
|
|
final TokenType type;
|
|
|
|
final String text;
|
2017-07-05 22:44:13 +00:00
|
|
|
FileSpan span;
|
2017-01-22 23:15:53 +00:00
|
|
|
|
|
|
|
Token(this.type, this.text, [this.span]);
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
2019-08-08 02:28:20 +00:00
|
|
|
if (span == null) {
|
2017-01-22 23:15:53 +00:00
|
|
|
return "'$text' -> $type";
|
2019-08-08 02:28:20 +00:00
|
|
|
} else {
|
2017-01-22 23:15:53 +00:00
|
|
|
return "(${span.start.line}:${span.start.column}) '$text' -> $type";
|
2019-08-08 02:28:20 +00:00
|
|
|
}
|
2017-01-22 23:15:53 +00:00
|
|
|
}
|
|
|
|
}
|