fix: compiling but not working -- need debug
This commit is contained in:
parent
1eecb1bd42
commit
04529f858c
4 changed files with 11 additions and 3 deletions
|
|
@ -96,7 +96,9 @@ ssize_t stream_read(char **stream)
|
|||
else if (context.mode == IOB_MODE_CMD)
|
||||
{
|
||||
*stream = context.args;
|
||||
return strlen(context.args);
|
||||
size_t len = strlen(context.args);
|
||||
context.args[len] = EOF;
|
||||
return len;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
static char *end_last_token;
|
||||
static ssize_t remaining_chars;
|
||||
static bool at_beginning = true;
|
||||
|
||||
/* @brief: saves state for the next call the the lexer.
|
||||
*
|
||||
|
|
@ -20,6 +21,7 @@ static void save_state(char *stream, ssize_t i)
|
|||
{
|
||||
remaining_chars -= i;
|
||||
end_last_token = stream + i;
|
||||
at_beginning = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -43,6 +45,7 @@ static void set_token_spechar(struct token *tok, char *begin, ssize_t size)
|
|||
if (begin[0] == EOF)
|
||||
{
|
||||
tok->type = TOKEN_EOF;
|
||||
remaining_chars = 0;
|
||||
}
|
||||
else if (begin[0] == ';')
|
||||
{
|
||||
|
|
@ -100,6 +103,7 @@ static void set_token_word(struct token *tok, char *begin, ssize_t size)
|
|||
{
|
||||
if (tok->type == TOKEN_NULL)
|
||||
{
|
||||
tok->type = TOKEN_WORD;
|
||||
tok->data = calloc(size + 1, sizeof(char));
|
||||
if (tok->data == NULL)
|
||||
return;
|
||||
|
|
@ -133,9 +137,10 @@ char *stream_init(void)
|
|||
{
|
||||
char *stream;
|
||||
|
||||
if (remaining_chars == 0)
|
||||
if (at_beginning)
|
||||
{
|
||||
remaining_chars = stream_read(&stream);
|
||||
// at_beginning = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ struct ast *get_ast()
|
|||
token = pop_token();
|
||||
break;
|
||||
}
|
||||
token = peek_token();
|
||||
}
|
||||
|
||||
if (token == NULL)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ static bool isterminator(struct token *token)
|
|||
struct ast *parse_simple_command(void)
|
||||
{
|
||||
struct list *command_elements = NULL;
|
||||
struct token *token = POP_TOKEN();
|
||||
struct token *token = PEEK_TOKEN();
|
||||
|
||||
while (!isterminator(token))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue