irishman 1.0.1 irishman: ^1.0.1 copied to clipboard
A generic programming language interpreter, linter, formatter, and all that jazz, written in Dart.
import 'package:irishman/irishman.dart';
void main() {
var tokenizer = Tokenizer(
keywords: const [
Keyword("if"),
Keyword("else"),
],
symbols: const [
Symbol(">=", "Greater than or equals"),
Symbol("(", "Start Paren"),
Symbol(")", "End Paren"),
Symbol("{", "Increase Scope"),
Symbol("}", "Decrease Scope"),
],
spans: [
Span(
"Comment Block",
start: "/*",
end: "*/",
),
Span(
"Line Comment",
start: "//",
end: "\n",
),
Span(
"Identifier",
initiator: RegExp("[a-zA-Z]"),
conditional: RegExp("[a-zA-Z0-9]"),
),
],
);
print(
'All the token constants are: \n - ${tokenizer.getAllTokenNames().join("\n - ")}');
print("");
print("The output to `if (4 >= 4) { } else { }` is:");
print(tokenizer
.tokenizeString(
"if (4 >= 4) { /* run this code */ } else { /* run this */ }")
.map((e) => "${e.tokenName}:${e.data}")
.join(", "));
}