From 0bba31912665a82f848642e6b4247071a3ee177a Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 17 Mar 2025 19:29:28 -0400 Subject: 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 --- parse.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'parse.c') 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("", 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 -- cgit v1.2.3