bshell: re-organise build into three separate components
bshell: the front-end binary bshell.runtime: contains the parser, compiler, and classes needed to run bshell scripts bshell.core: contains the builtin commandlets and aliases
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#include "syntax.h"
|
||||
|
||||
#include <bshell/ast.h>
|
||||
#include <bshell/parse/lex.h>
|
||||
#include <bshell/parse/parse.h>
|
||||
#include <bshell/parse/token.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
enum bshell_status bshell_parse_ctx_init(struct bshell_parse_ctx *ctx, struct bshell_lex_ctx *src)
|
||||
{
|
||||
memset(ctx, 0x0, sizeof *ctx);
|
||||
|
||||
ctx->p_src = src;
|
||||
|
||||
return BSHELL_SUCCESS;
|
||||
}
|
||||
|
||||
void bshell_parse_ctx_cleanup(struct bshell_parse_ctx *ctx)
|
||||
{
|
||||
}
|
||||
|
||||
struct bshell_ast_node *bshell_parse_ctx_read_node(struct bshell_parse_ctx *ctx)
|
||||
{
|
||||
parse_symbol(ctx, BSHELL_SYM_SEMICOLON);
|
||||
parse_linefeed(ctx);
|
||||
|
||||
struct bshell_ast_node *result = NULL;
|
||||
bool ok = parse_statement(ctx, &result);
|
||||
|
||||
return ok ? result : NULL;
|
||||
}
|
||||
|
||||
void report_error(struct bshell_parse_ctx *ctx, const char *format, ...)
|
||||
{
|
||||
ctx->p_status = BSHELL_ERR_BAD_SYNTAX;
|
||||
fprintf(stderr, "PARSE: ");
|
||||
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
vfprintf(stderr, format, arg);
|
||||
va_end(arg);
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
struct bshell_lex_token *tok = peek_token(ctx);
|
||||
fprintf(stderr, " peek_token = ");
|
||||
#if 0
|
||||
if (tok) {
|
||||
print_bshell_lex_token(tok);
|
||||
} else {
|
||||
fprintf(stderr, " EOF\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user