Commit b52d2107 authored by Dominik Charousset's avatar Dominik Charousset

Emit ec::unexpected_newline automatically

parent 4c894a79
...@@ -18,6 +18,13 @@ ...@@ -18,6 +18,13 @@
#pragma once #pragma once
#define CAF_FSM_EVAL_MISMATCH_EC \
if (mismatch_ec == ec::unexpected_character) \
ps.code = ch != '\n' ? mismatch_ec : ec::unexpected_newline; \
else \
ps.code = mismatch_ec; \
return;
#define start() \ #define start() \
char ch = ps.current(); \ char ch = ps.current(); \
goto s_init; \ goto s_init; \
...@@ -28,8 +35,7 @@ ...@@ -28,8 +35,7 @@
static constexpr ec mismatch_ec = ec::unexpected_character static constexpr ec mismatch_ec = ec::unexpected_character
#define state(name) \ #define state(name) \
ps.code = mismatch_ec; \ CAF_FSM_EVAL_MISMATCH_EC \
return; \
} \ } \
{ \ { \
static constexpr ec mismatch_ec = ec::unexpected_character; \ static constexpr ec mismatch_ec = ec::unexpected_character; \
...@@ -39,8 +45,7 @@ ...@@ -39,8 +45,7 @@
e_##name : __attribute__((unused)); e_##name : __attribute__((unused));
#define term_state(name) \ #define term_state(name) \
ps.code = mismatch_ec; \ CAF_FSM_EVAL_MISMATCH_EC \
return; \
} \ } \
{ \ { \
static constexpr ec mismatch_ec = ec::trailing_character; \ static constexpr ec mismatch_ec = ec::trailing_character; \
...@@ -50,8 +55,7 @@ ...@@ -50,8 +55,7 @@
e_##name : __attribute__((unused)); e_##name : __attribute__((unused));
#define fin() \ #define fin() \
ps.code = mismatch_ec; \ CAF_FSM_EVAL_MISMATCH_EC \
return; \
} \ } \
s_fin: \ s_fin: \
ps.code = ec::success; \ ps.code = ec::success; \
......
...@@ -64,7 +64,6 @@ void read_atom(state<Iterator, Sentinel>& ps, Consumer& consumer) { ...@@ -64,7 +64,6 @@ void read_atom(state<Iterator, Sentinel>& ps, Consumer& consumer) {
state(read_chars) { state(read_chars) {
input(is_char<'\''>, done) input(is_char<'\''>, done)
checked_action(is_legal, read_chars, append(ch), ec::too_many_characters) checked_action(is_legal, read_chars, append(ch), ec::too_many_characters)
invalid_input(is_char<'\n'>, ec::unexpected_newline)
} }
term_state(done) { term_state(done) {
input(is_char<' '>, done) input(is_char<' '>, done)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment