Compare commits
2 Commits
5f72602471
...
a0b204fadd
| Author | SHA1 | Date | |
|---|---|---|---|
| a0b204fadd | |||
| 19c7587f28 |
+23
-1
@@ -58,6 +58,28 @@ static const char *toktab[] = {
|
|||||||
[TT_U64] = qtok("u64")
|
[TT_U64] = qtok("u64")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
parser_nom(struct cescal_state *state, struct token *res)
|
||||||
|
{
|
||||||
|
struct token tok;
|
||||||
|
|
||||||
|
if (state == NULL || res == NULL) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lexer_nom(state, &tok) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tokbuf_push(&state->tokbuf, &tok) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*res = tok;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
parser_parse(struct cescal_state *state)
|
parser_parse(struct cescal_state *state)
|
||||||
{
|
{
|
||||||
@@ -68,7 +90,7 @@ parser_parse(struct cescal_state *state)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (lexer_nom(state, &tok) == 0) {
|
while (parser_nom(state, &tok) == 0) {
|
||||||
cc_trace("got token %s\n", tokstr(&tok));
|
cc_trace("got token %s\n", tokstr(&tok));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ tokbuf_push(struct tokbuf *tokbuf, struct token *tok)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tokbuf->head++) >= TOKBUF_CAP) {
|
if ((tokbuf->head++) >= TOKBUF_CAP - 1) {
|
||||||
tokbuf->head = 0;
|
tokbuf->head = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user