diff options
Diffstat (limited to 'libparser-generate.c')
| -rw-r--r-- | libparser-generate.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libparser-generate.c b/libparser-generate.c index f72ed85..a8761f8 100644 --- a/libparser-generate.c +++ b/libparser-generate.c @@ -375,6 +375,7 @@ emit_and_free_sentence(struct node *node, size_t *indexp) switch (node->token->s[0]) { case '[': type = "OPTIONAL"; goto unary; case '{': type = "REPEATED"; goto unary; + case '+': type = "COMMITTED"; goto unary; case '!': type = "REJECTION"; unary: emit_and_free_sentence(node->data, indexp); printf("static union libparser_sentence sentence_%zu_%zu = {.unary = {" @@ -501,6 +502,7 @@ order_sentences(struct node *node) case '[': case '{': case '!': + case '+': /* Everything else we immediately put into the queue, * but for brackets and unary operators, we simply * use recursion to order inner sentences */ @@ -699,10 +701,11 @@ again: * closing statements; and we still expect * the next token to be an operand */ goto push_stack; - } else if (tokens[i]->s[0] == '!') { - /* Likewise for rejections (it is added to - * the stack but it is an unary operator - * so no matching symbol will be expected) */ + } else if (tokens[i]->s[0] == '!' || tokens[i]->s[0] == '+') { + /* Likewise for rejections and commitments + * (it is added to the stack but they are + * unary operators so no matching symbol + * will be expected) */ goto push_stack; } else if (tokens[i]->s[0] == '<') { /* Likewise for value ranges, but we expect @@ -741,8 +744,8 @@ again: case EXPECT_OPERATOR: /* When we get an binary operator, or the end * of a sentence, we have to pop out all unary - * operators (rejects) from the stack */ - while (stack->token->s[0] == '!') { + * operators from the stack */ + while (stack->token->s[0] == '!' || stack->token->s[0] == '+') { *stack->parent->head = stack; stack->parent->head = &stack->next; stack = stack->parent; |
