diff options
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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 |
