summaryrefslogtreecommitdiff
path: root/sh9parser.m
diff options
context:
space:
mode:
authorKonstantin Kirik (snegovick) <snegovick@uprojects.org>2025-12-12 03:51:07 +0300
committerKonstantin Kirik (snegovick) <snegovick@uprojects.org>2025-12-12 03:51:07 +0300
commita40ef1434889babbd88c9d0c5913c70e96ac2774 (patch)
treea71e4f3cb1d6056554e3958468ddfcee0300e08e /sh9parser.m
parentcc280d7e5d07fd61e45825b3850c8baaa4147639 (diff)
Add simple parser for future shell-like lang
Diffstat (limited to 'sh9parser.m')
-rw-r--r--sh9parser.m28
1 files changed, 28 insertions, 0 deletions
diff --git a/sh9parser.m b/sh9parser.m
new file mode 100644
index 0000000..cbad2f6
--- /dev/null
+++ b/sh9parser.m
@@ -0,0 +1,28 @@
+Sh9Parser: module
+{
+PATH: con "sh9parser.dis";
+DESCR: con "Mostly generic parser for sh9";
+
+mk_tok: fn(start: int, line: int, tok: string, typ: string) : TokNode;
+set_last_tok: fn(last_tok: ref TokNode, toks: list of ref TokNode): (TokNode, list of ref TokNode);
+print_toks: fn(toks: array of ref TokNode);
+print_toks_short: fn(toks: array of ref TokNode);
+check_grammar_node_match: fn(toks: array of ref TokNode, gn: ref GrammarNode): int;
+replace_toks: fn(src: array of ref TokNode, replace_start: int, replace_len: int, replace_with: array of ref TokNode): array of ref TokNode;
+parse_toks: fn(toks: array of ref TokNode, g: array of ref GrammarNode): array of ref TokNode;
+
+TokNode: adt {
+ start: int;
+ line: int;
+ tok: string;
+ typ: string;
+};
+
+GrammarNode: adt {
+ expr: array of string;
+ transform: string;
+
+ callback: ref fn(toks: array of ref TokNode);
+ print_expr: fn(gn: self ref GrammarNode);
+};
+};