Fixed bug in behaviour of counting parser. Removed changelog (git is the changelog).
This commit is contained in:
@@ -1,17 +0,0 @@
|
|||||||
# Oct. 17, 2014; Daniel Holden
|
|
||||||
- Reverted state to use long type
|
|
||||||
|
|
||||||
# Oct. 16, 2014; Daniel Holden
|
|
||||||
- Removed comments describing changes
|
|
||||||
- Fixed warnings reported by gcc in test suite under the new compilation flags
|
|
||||||
|
|
||||||
# Oct. 14, 2014; Dalton Woodard
|
|
||||||
- Fixed all compilation warnings in `mpc.h` and `mpc.c`; both now compile successfully on OS X under clang-600.0.51
|
|
||||||
and gcc 4.9.1 with the following flags:
|
|
||||||
```
|
|
||||||
-std=c11 -O3 -g -Werror -Wall -Wextra -Wformat=2 -Wshadow -Wno-format-nonliteral -Wcast-align -Wwrite-strings
|
|
||||||
-Wstrict-prototypes -Wold-style-definition -Wredundant-decls -Wnested-externs -Wmissing-include-dirs -Wswitch-default
|
|
||||||
```
|
|
||||||
- Changed compilation standard from ansi to c11.
|
|
||||||
- Further small changes in source (documented in-line).
|
|
||||||
|
|
@@ -1,7 +1,7 @@
|
|||||||
Micro Parser Combinators
|
Micro Parser Combinators
|
||||||
========================
|
========================
|
||||||
|
|
||||||
Version 0.8.5
|
Version 0.8.6
|
||||||
|
|
||||||
|
|
||||||
About
|
About
|
||||||
|
18
mpc.c
18
mpc.c
@@ -1112,19 +1112,17 @@ int mpc_parse_input(mpc_input_t *i, mpc_parser_t *init, mpc_result_t *final) {
|
|||||||
case MPC_TYPE_COUNT:
|
case MPC_TYPE_COUNT:
|
||||||
if (st == 0) { mpc_input_mark(i); MPC_CONTINUE(st+1, p->data.repeat.x); }
|
if (st == 0) { mpc_input_mark(i); MPC_CONTINUE(st+1, p->data.repeat.x); }
|
||||||
if (st > 0) {
|
if (st > 0) {
|
||||||
if (mpc_stack_peekr(stk, &r)) {
|
if (!mpc_stack_peekr(stk, &r)) {
|
||||||
MPC_CONTINUE(st+1, p->data.repeat.x);
|
mpc_stack_popr(stk, &r);
|
||||||
|
mpc_stack_popr_out_single(stk, st-1, p->data.repeat.dx);
|
||||||
|
mpc_input_rewind(i);
|
||||||
|
MPC_FAILURE(mpc_err_count(r.error, p->data.repeat.n));
|
||||||
} else {
|
} else {
|
||||||
if (st != (p->data.repeat.n+1)) {
|
if (st < p->data.repeat.n) {
|
||||||
mpc_stack_popr(stk, &r);
|
MPC_CONTINUE(st+1, p->data.repeat.x);
|
||||||
mpc_stack_popr_out_single(stk, st-1, p->data.repeat.dx);
|
|
||||||
mpc_input_rewind(i);
|
|
||||||
MPC_FAILURE(mpc_err_count(r.error, p->data.repeat.n));
|
|
||||||
} else {
|
} else {
|
||||||
mpc_stack_popr(stk, &r);
|
|
||||||
mpc_stack_err(stk, r.error);
|
|
||||||
mpc_input_unmark(i);
|
mpc_input_unmark(i);
|
||||||
MPC_SUCCESS(mpc_stack_merger_out(stk, st-1, p->data.repeat.f));
|
MPC_SUCCESS(mpc_stack_merger_out(stk, st, p->data.repeat.f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
38
tests/core.c
38
tests/core.c
@@ -85,8 +85,38 @@ void test_strip(void) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void suite_core(void) {
|
void test_repeat(void) {
|
||||||
pt_add_test(test_ident, "Test Ident", "Suite Core");
|
|
||||||
pt_add_test(test_maths, "Test Maths", "Suite Core");
|
int success;
|
||||||
pt_add_test(test_strip, "Test Strip", "Suite Core");
|
mpc_result_t r;
|
||||||
|
mpc_parser_t *p = mpc_count(3, mpcf_strfold, mpc_digit(), free);
|
||||||
|
|
||||||
|
success = mpc_parse("test", "046", p, &r);
|
||||||
|
PT_ASSERT(success);
|
||||||
|
PT_ASSERT_STR_EQ(r.output, "046");
|
||||||
|
free(r.output);
|
||||||
|
|
||||||
|
success = mpc_parse("test", "046aa", p, &r);
|
||||||
|
PT_ASSERT(success);
|
||||||
|
PT_ASSERT_STR_EQ(r.output, "046");
|
||||||
|
free(r.output);
|
||||||
|
|
||||||
|
success = mpc_parse("test", "04632", p, &r);
|
||||||
|
PT_ASSERT(success);
|
||||||
|
PT_ASSERT_STR_EQ(r.output, "046");
|
||||||
|
free(r.output);
|
||||||
|
|
||||||
|
success = mpc_parse("test", "04", p, &r);
|
||||||
|
PT_ASSERT(!success);
|
||||||
|
mpc_err_delete(r.error);
|
||||||
|
|
||||||
|
mpc_delete(p);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void suite_core(void) {
|
||||||
|
pt_add_test(test_ident, "Test Ident", "Suite Core");
|
||||||
|
pt_add_test(test_maths, "Test Maths", "Suite Core");
|
||||||
|
pt_add_test(test_strip, "Test Strip", "Suite Core");
|
||||||
|
pt_add_test(test_repeat, "Test Repeat", "Suite Core");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user