aboutsummaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-17 19:29:28 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-17 19:29:28 -0400
commit0bba31912665a82f848642e6b4247071a3ee177a (patch)
treeae5c3ac7501a0841c9a858d6559a0dfb7db69035 /parse.c
parent94993c5f113b27083e586c7620eb896fe750c6d1 (diff)
Big overhaul:
- Clean up environment code using type strings instead of manually defining types - Add Commands module - Move Shell lang into an example module that uses Commands module - Fix some bugs with chained library dependencies
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/parse.c b/parse.c
index 757c8cb3..5110e98e 100644
--- a/parse.c
+++ b/parse.c
@@ -1377,8 +1377,6 @@ PARSER(parse_text) {
if (!lang && (open_quote == '/' || open_quote == '|'))
lang = "Pattern";
- else if (!lang && open_quote == '(')
- lang = "Shell";
} else {
return NULL;
}
@@ -2604,4 +2602,21 @@ type_ast_t *parse_type_str(const char *str) {
return ast;
}
+ast_t *parse(const char *str) {
+ file_t *file = spoof_file("<string>", str);
+ parse_ctx_t ctx = {
+ .file=file,
+ .on_err=NULL,
+ };
+
+ const char *pos = file->text;
+ whitespace(&pos);
+ ast_t *ast = parse_file_body(&ctx, pos);
+ pos = ast->end;
+ whitespace(&pos);
+ if (pos < file->text + file->len && *pos != '\0')
+ parser_err(&ctx, pos, pos + strlen(pos), "I couldn't parse this part of the file");
+ return ast;
+}
+
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0