From 7dd4970daafdc1992e1dba486a1477a17cb4c53e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 5 Jan 2026 13:50:38 +0100 Subject: Add committed-operator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libparser-generate.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'libparser-generate.c') 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; -- cgit v1.2.3-70-g09d2