Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
d4cf1f7a
Commit
d4cf1f7a
authored
May 25, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplifiy DSL for FSM declarations
parent
115b4fd0
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
359 additions
and
236 deletions
+359
-236
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+1
-0
libcaf_core/caf/detail/parser/fsm.hpp
libcaf_core/caf/detail/parser/fsm.hpp
+117
-40
libcaf_core/caf/detail/parser/read_atom.hpp
libcaf_core/caf/detail/parser/read_atom.hpp
+5
-7
libcaf_core/caf/detail/parser/read_bool.hpp
libcaf_core/caf/detail/parser/read_bool.hpp
+10
-13
libcaf_core/caf/detail/parser/read_ini.hpp
libcaf_core/caf/detail/parser/read_ini.hpp
+55
-78
libcaf_core/caf/detail/parser/read_number.hpp
libcaf_core/caf/detail/parser/read_number.hpp
+48
-55
libcaf_core/caf/detail/parser/read_number_or_timespan.hpp
libcaf_core/caf/detail/parser/read_number_or_timespan.hpp
+13
-16
libcaf_core/caf/detail/parser/read_string.hpp
libcaf_core/caf/detail/parser/read_string.hpp
+13
-15
libcaf_core/caf/detail/pp.hpp
libcaf_core/caf/detail/pp.hpp
+46
-0
libcaf_core/src/fsm.cpp
libcaf_core/src/fsm.cpp
+39
-0
libcaf_core/test/read_bool.cpp
libcaf_core/test/read_bool.cpp
+2
-12
libcaf_core/test/read_ini.cpp
libcaf_core/test/read_ini.cpp
+10
-0
No files found.
libcaf_core/CMakeLists.txt
View file @
d4cf1f7a
...
@@ -52,6 +52,7 @@ set(LIBCAF_CORE_SRCS
...
@@ -52,6 +52,7 @@ set(LIBCAF_CORE_SRCS
src/execution_unit.cpp
src/execution_unit.cpp
src/exit_reason.cpp
src/exit_reason.cpp
src/forwarding_actor_proxy.cpp
src/forwarding_actor_proxy.cpp
src/fsm.cpp
src/get_mac_addresses.cpp
src/get_mac_addresses.cpp
src/get_process_id.cpp
src/get_process_id.cpp
src/get_root_uuid.cpp
src/get_root_uuid.cpp
...
...
libcaf_core/caf/detail/parser/fsm.hpp
View file @
d4cf1f7a
This diff is collapsed.
Click to expand it.
libcaf_core/caf/detail/parser/read_atom.hpp
View file @
d4cf1f7a
...
@@ -57,17 +57,15 @@ void read_atom(state<Iterator, Sentinel>& ps, Consumer& consumer) {
...
@@ -57,17 +57,15 @@ void read_atom(state<Iterator, Sentinel>& ps, Consumer& consumer) {
});
});
start
();
start
();
state
(
init
)
{
state
(
init
)
{
input
(
is_char
<
' '
>
,
init
)
transition
(
init
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
init
)
transition
(
read_chars
,
'\''
)
input
(
is_char
<
'\''
>
,
read_chars
)
}
}
state
(
read_chars
)
{
state
(
read_chars
)
{
input
(
is_char
<
'\''
>
,
done
)
transition
(
done
,
'\''
)
checked_action
(
is_legal
,
read_chars
,
append
(
ch
),
ec
::
too_many_characters
)
transition
(
read_chars
,
is_legal
,
append
(
ch
),
ec
::
too_many_characters
)
}
}
term_state
(
done
)
{
term_state
(
done
)
{
input
(
is_char
<
' '
>
,
done
)
transition
(
done
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
done
)
}
}
fin
();
fin
();
}
}
...
...
libcaf_core/caf/detail/parser/read_bool.hpp
View file @
d4cf1f7a
...
@@ -42,35 +42,32 @@ void read_bool(state<Iterator, Sentinel>& ps, Consumer& consumer) {
...
@@ -42,35 +42,32 @@ void read_bool(state<Iterator, Sentinel>& ps, Consumer& consumer) {
});
});
start
();
start
();
state
(
init
)
{
state
(
init
)
{
input
(
is_char
<
' '
>
,
init
)
transition
(
has_f
,
'f'
)
input
(
is_char
<
'\t'
>
,
init
)
transition
(
has_t
,
't'
)
input
(
is_char
<
'f'
>
,
has_f
)
input
(
is_char
<
't'
>
,
has_t
)
}
}
state
(
has_f
)
{
state
(
has_f
)
{
input
(
is_char
<
'a'
>
,
has_fa
)
transition
(
has_fa
,
'a'
)
}
}
state
(
has_fa
)
{
state
(
has_fa
)
{
input
(
is_char
<
'l'
>
,
has_fal
)
transition
(
has_fal
,
'l'
)
}
}
state
(
has_fal
)
{
state
(
has_fal
)
{
input
(
is_char
<
's'
>
,
has_fals
)
transition
(
has_fals
,
's'
)
}
}
state
(
has_fals
)
{
state
(
has_fals
)
{
action
(
is_char
<
'e'
>
,
done
,
res
=
false
)
transition
(
done
,
'e'
,
res
=
false
)
}
}
state
(
has_t
)
{
state
(
has_t
)
{
input
(
is_char
<
'r'
>
,
has_tr
)
transition
(
has_tr
,
'r'
)
}
}
state
(
has_tr
)
{
state
(
has_tr
)
{
input
(
is_char
<
'u'
>
,
has_tru
)
transition
(
has_tru
,
'u'
)
}
}
state
(
has_tru
)
{
state
(
has_tru
)
{
action
(
is_char
<
'e'
>
,
done
,
res
=
true
)
transition
(
done
,
'e'
,
res
=
true
)
}
}
term_state
(
done
)
{
term_state
(
done
)
{
input
(
is_char
<
' '
>
,
done
)
// nop
input
(
is_char
<
'\t'
>
,
done
)
}
}
fin
();
fin
();
}
}
...
...
libcaf_core/caf/detail/parser/read_ini.hpp
View file @
d4cf1f7a
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#include "caf/detail/parser/ec.hpp"
#include "caf/detail/parser/ec.hpp"
#include "caf/detail/parser/fsm.hpp"
#include "caf/detail/parser/fsm.hpp"
#include "caf/detail/parser/is_char.hpp"
#include "caf/detail/parser/read_atom.hpp"
#include "caf/detail/parser/read_atom.hpp"
#include "caf/detail/parser/read_bool.hpp"
#include "caf/detail/parser/read_bool.hpp"
#include "caf/detail/parser/read_number_or_timespan.hpp"
#include "caf/detail/parser/read_number_or_timespan.hpp"
...
@@ -56,11 +55,11 @@ template <class Iterator, class Sentinel, class Consumer>
...
@@ -56,11 +55,11 @@ template <class Iterator, class Sentinel, class Consumer>
void
read_ini_comment
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
)
{
void
read_ini_comment
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
)
{
start
();
start
();
state
(
init
)
{
state
(
init
)
{
input
(
is_char
<
';'
>
,
await_newline
)
transition
(
await_newline
,
';'
)
}
}
term_state
(
await_newline
)
{
term_state
(
await_newline
)
{
input
(
is_char
<
'\n'
>
,
done
)
transition
(
done
,
'\n'
)
any_input
(
await_newline
)
transition
(
await_newline
)
}
}
term_state
(
done
)
{
term_state
(
done
)
{
// nop
// nop
...
@@ -75,23 +74,19 @@ template <class Iterator, class Sentinel, class Consumer>
...
@@ -75,23 +74,19 @@ template <class Iterator, class Sentinel, class Consumer>
void
read_ini_list
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
consumer
)
{
void
read_ini_list
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
consumer
)
{
start
();
start
();
state
(
init
)
{
state
(
init
)
{
action
(
is_char
<
'['
>
,
before_value
,
consumer
.
begin_list
())
transition
(
before_value
,
'['
,
consumer
.
begin_list
())
}
}
state
(
before_value
)
{
state
(
before_value
)
{
input
(
is_char
<
' '
>
,
before_value
)
transition
(
before_value
,
"
\t\n
"
)
input
(
is_char
<
'\t'
>
,
before_value
)
transition
(
done
,
']'
,
consumer
.
end_list
())
input
(
is_char
<
'\n'
>
,
before_value
)
fsm_epsilon
(
read_ini_comment
(
ps
,
consumer
),
before_value
,
';'
)
action
(
is_char
<
']'
>
,
done
,
consumer
.
end_list
())
fsm_epsilon
(
read_ini_value
(
ps
,
consumer
),
after_value
)
invoke_fsm_if
(
is_char
<
';'
>
,
read_ini_comment
(
ps
,
consumer
),
before_value
)
invoke_fsm
(
read_ini_value
(
ps
,
consumer
),
after_value
)
}
}
state
(
after_value
)
{
state
(
after_value
)
{
input
(
is_char
<
' '
>
,
after_value
)
transition
(
after_value
,
"
\t\n
"
)
input
(
is_char
<
'\t'
>
,
after_value
)
transition
(
before_value
,
','
)
input
(
is_char
<
'\n'
>
,
after_value
)
transition
(
done
,
']'
,
consumer
.
end_list
())
input
(
is_char
<
','
>
,
before_value
)
fsm_epsilon
(
read_ini_comment
(
ps
,
consumer
),
after_value
,
';'
)
action
(
is_char
<
']'
>
,
done
,
consumer
.
end_list
())
invoke_fsm_if
(
is_char
<
';'
>
,
read_ini_comment
(
ps
,
consumer
),
after_value
)
}
}
term_state
(
done
)
{
term_state
(
done
)
{
// nop
// nop
...
@@ -102,46 +97,40 @@ void read_ini_list(state<Iterator, Sentinel>& ps, Consumer& consumer) {
...
@@ -102,46 +97,40 @@ void read_ini_list(state<Iterator, Sentinel>& ps, Consumer& consumer) {
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
void
read_ini_map
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
consumer
)
{
void
read_ini_map
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
consumer
)
{
std
::
string
key
;
std
::
string
key
;
auto
is_
alnum_or_dash
=
[](
char
x
)
{
auto
alnum_or_dash
=
[](
char
x
)
{
return
isalnum
(
x
)
||
x
==
'-'
||
x
==
'_'
;
return
isalnum
(
x
)
||
x
==
'-'
||
x
==
'_'
;
};
};
start
();
start
();
state
(
init
)
{
state
(
init
)
{
action
(
is_char
<
'{'
>
,
await_key_name
,
consumer
.
begin_map
())
transition
(
await_key_name
,
'{'
,
consumer
.
begin_map
())
}
}
state
(
await_key_name
)
{
state
(
await_key_name
)
{
input
(
is_char
<
' '
>
,
await_key_name
)
transition
(
await_key_name
,
"
\t\n
"
)
input
(
is_char
<
'\t'
>
,
await_key_name
)
fsm_epsilon
(
read_ini_comment
(
ps
,
consumer
),
await_key_name
,
';'
)
input
(
is_char
<
'\n'
>
,
await_key_name
)
transition
(
read_key_name
,
alphabetic_chars
,
key
=
ch
)
invoke_fsm_if
(
is_char
<
';'
>
,
read_ini_comment
(
ps
,
consumer
),
await_key_name
)
transition
(
done
,
'}'
,
consumer
.
end_map
())
action
(
isalnum
,
read_key_name
,
key
=
ch
)
action
(
is_char
<
'}'
>
,
done
,
consumer
.
end_map
())
}
}
// Reads a key of a "key=value" line.
// Reads a key of a "key=value" line.
state
(
read_key_name
)
{
state
(
read_key_name
)
{
action
(
is_alnum_or_dash
,
read_key_name
,
key
+=
ch
)
transition
(
read_key_name
,
alnum_or_dash
,
key
+=
ch
)
epsilon
(
await_assignment
)
epsilon
(
await_assignment
)
}
}
// Reads the assignment operator in a "key=value" line.
// Reads the assignment operator in a "key=value" line.
state
(
await_assignment
)
{
state
(
await_assignment
)
{
input
(
is_char
<
' '
>
,
await_assignment
)
transition
(
await_assignment
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
await_assignment
)
transition
(
await_value
,
'='
,
consumer
.
key
(
std
::
move
(
key
)))
action
(
is_char
<
'='
>
,
await_value
,
consumer
.
key
(
std
::
move
(
key
)))
}
}
// Reads the value in a "key=value" line.
// Reads the value in a "key=value" line.
state
(
await_value
)
{
state
(
await_value
)
{
input
(
is_char
<
' '
>
,
await_value
)
transition
(
await_value
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
await_value
)
fsm_epsilon
(
read_ini_value
(
ps
,
consumer
),
after_value
)
invoke_fsm
(
read_ini_value
(
ps
,
consumer
),
after_value
)
}
}
// Waits for end-of-line after reading a value
// Waits for end-of-line after reading a value
state
(
after_value
)
{
state
(
after_value
)
{
input
(
is_char
<
' '
>
,
after_value
)
transition
(
after_value
,
"
\t\n
"
)
input
(
is_char
<
'\t'
>
,
after_value
)
transition
(
await_key_name
,
','
)
input
(
is_char
<
'\n'
>
,
after_value
)
transition
(
done
,
'}'
,
consumer
.
end_map
())
input
(
is_char
<
','
>
,
await_key_name
)
fsm_epsilon
(
read_ini_comment
(
ps
,
consumer
),
after_value
,
';'
)
action
(
is_char
<
'}'
>
,
done
,
consumer
.
end_map
())
invoke_fsm_if
(
is_char
<
';'
>
,
read_ini_comment
(
ps
,
consumer
),
after_value
)
}
}
term_state
(
done
)
{
term_state
(
done
)
{
//nop
//nop
...
@@ -151,18 +140,15 @@ void read_ini_map(state<Iterator, Sentinel>& ps, Consumer& consumer) {
...
@@ -151,18 +140,15 @@ void read_ini_map(state<Iterator, Sentinel>& ps, Consumer& consumer) {
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
void
read_ini_value
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
consumer
)
{
void
read_ini_value
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
consumer
)
{
auto
is_f_or_t
=
[](
char
x
)
{
return
x
==
'f'
||
x
==
'F'
||
x
==
't'
||
x
==
'T'
;
};
start
();
start
();
state
(
init
)
{
state
(
init
)
{
invoke_fsm_if
(
is_char
<
'"'
>
,
read_string
(
ps
,
consumer
),
done
)
fsm_epsilon
(
read_string
(
ps
,
consumer
),
done
,
'"'
)
invoke_fsm_if
(
is_char
<
'\''
>
,
read_atom
(
ps
,
consumer
),
done
)
fsm_epsilon
(
read_atom
(
ps
,
consumer
),
done
,
'\''
)
invoke_fsm_if
(
is_char
<
'.'
>
,
read_number
(
ps
,
consumer
),
done
)
fsm_epsilon
(
read_number
(
ps
,
consumer
),
done
,
'.'
)
invoke_fsm_if
(
is_f_or_t
,
read_bool
(
ps
,
consumer
),
done
)
fsm_epsilon
(
read_bool
(
ps
,
consumer
),
done
,
"ft"
)
invoke_fsm_if
(
isdigit
,
read_number_or_timespan
(
ps
,
consumer
),
done
)
fsm_epsilon
(
read_number_or_timespan
(
ps
,
consumer
),
done
,
decimal_chars
)
invoke_fsm_if
(
is_char
<
'['
>
,
read_ini_list
(
ps
,
consumer
),
done
)
fsm_epsilon
(
read_ini_list
(
ps
,
consumer
),
done
,
'['
)
invoke_fsm_if
(
is_char
<
'{'
>
,
read_ini_map
(
ps
,
consumer
),
done
)
fsm_epsilon
(
read_ini_map
(
ps
,
consumer
),
done
,
'{'
)
}
}
term_state
(
done
)
{
term_state
(
done
)
{
// nop
// nop
...
@@ -175,7 +161,7 @@ template <class Iterator, class Sentinel, class Consumer>
...
@@ -175,7 +161,7 @@ template <class Iterator, class Sentinel, class Consumer>
void
read_ini
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
consumer
)
{
void
read_ini
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
consumer
)
{
using
std
::
swap
;
using
std
::
swap
;
std
::
string
tmp
;
std
::
string
tmp
;
auto
is_
alnum_or_dash
=
[](
char
x
)
{
auto
alnum_or_dash
=
[](
char
x
)
{
return
isalnum
(
x
)
||
x
==
'-'
||
x
==
'_'
;
return
isalnum
(
x
)
||
x
==
'-'
||
x
==
'_'
;
};
};
bool
in_section
=
false
;
bool
in_section
=
false
;
...
@@ -199,61 +185,52 @@ void read_ini(state<Iterator, Sentinel>& ps, Consumer& consumer) {
...
@@ -199,61 +185,52 @@ void read_ini(state<Iterator, Sentinel>& ps, Consumer& consumer) {
start
();
start
();
// Scanning for first section.
// Scanning for first section.
term_state
(
init
)
{
term_state
(
init
)
{
input
(
is_char
<
' '
>
,
init
)
transition
(
init
,
"
\t\n
"
)
input
(
is_char
<
'\t'
>
,
init
)
fsm_epsilon
(
read_ini_comment
(
ps
,
consumer
),
init
,
';'
)
input
(
is_char
<
'\n'
>
,
init
)
transition
(
start_section
,
'['
)
invoke_fsm_if
(
is_char
<
';'
>
,
read_ini_comment
(
ps
,
consumer
),
init
)
input
(
is_char
<
'['
>
,
start_section
)
}
}
// Read the section key after reading an '['.
// Read the section key after reading an '['.
state
(
start_section
)
{
state
(
start_section
)
{
input
(
is_char
<
' '
>
,
start_section
)
transition
(
start_section
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
start_section
)
transition
(
read_section_name
,
alphabetic_chars
,
tmp
=
ch
)
action
(
isalpha
,
read_section_name
,
tmp
=
ch
)
}
}
// Reads a section name such as "[foo]".
// Reads a section name such as "[foo]".
state
(
read_section_name
)
{
state
(
read_section_name
)
{
action
(
is_alnum_or_dash
,
read_section_name
,
tmp
+=
ch
)
transition
(
read_section_name
,
alnum_or_dash
,
tmp
+=
ch
)
epsilon
(
close_section
)
epsilon
(
close_section
)
}
}
// Wait for the closing ']', preceded by any number of whitespaces.
// Wait for the closing ']', preceded by any number of whitespaces.
state
(
close_section
)
{
state
(
close_section
)
{
input
(
is_char
<
' '
>
,
close_section
)
transition
(
close_section
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
close_section
)
transition
(
dispatch
,
']'
,
begin_section
())
action
(
is_char
<
']'
>
,
dispatch
,
begin_section
())
}
}
// Dispatches to read sections, comments, or key/value pairs.
// Dispatches to read sections, comments, or key/value pairs.
term_state
(
dispatch
)
{
term_state
(
dispatch
)
{
input
(
is_char
<
' '
>
,
dispatch
)
transition
(
dispatch
,
"
\t\n
"
)
input
(
is_char
<
'\t'
>
,
dispatch
)
transition
(
read_section_name
,
'['
)
input
(
is_char
<
'\n'
>
,
dispatch
)
fsm_epsilon
(
read_ini_comment
(
ps
,
consumer
),
dispatch
,
';'
)
input
(
is_char
<
'['
>
,
read_section_name
)
transition
(
read_key_name
,
alphanumeric_chars
,
tmp
=
ch
)
invoke_fsm_if
(
is_char
<
';'
>
,
read_ini_comment
(
ps
,
consumer
),
dispatch
)
action
(
isalnum
,
read_key_name
,
tmp
=
ch
)
}
}
// Reads a key of a "key=value" line.
// Reads a key of a "key=value" line.
state
(
read_key_name
)
{
state
(
read_key_name
)
{
action
(
is_alnum_or_dash
,
read_key_name
,
tmp
+=
ch
)
transition
(
read_key_name
,
alnum_or_dash
,
tmp
+=
ch
)
epsilon
(
await_assignment
)
epsilon
(
await_assignment
)
}
}
// Reads the assignment operator in a "key=value" line.
// Reads the assignment operator in a "key=value" line.
state
(
await_assignment
)
{
state
(
await_assignment
)
{
input
(
is_char
<
' '
>
,
await_assignment
)
transition
(
await_assignment
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
await_assignment
)
transition
(
await_value
,
'='
,
emit_key
())
action
(
is_char
<
'='
>
,
await_value
,
emit_key
())
}
}
// Reads the value in a "key=value" line.
// Reads the value in a "key=value" line.
state
(
await_value
)
{
state
(
await_value
)
{
input
(
is_char
<
' '
>
,
await_value
)
transition
(
await_value
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
await_value
)
fsm_epsilon
(
read_ini_value
(
ps
,
consumer
),
await_eol
)
invoke_fsm
(
read_ini_value
(
ps
,
consumer
),
await_eol
)
}
}
// Waits for end-of-line after reading a value
// Waits for end-of-line after reading a value
term_state
(
await_eol
)
{
term_state
(
await_eol
)
{
input
(
is_char
<
' '
>
,
await_eol
)
transition
(
await_eol
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
await_eol
)
fsm_epsilon
(
read_ini_comment
(
ps
,
consumer
),
dispatch
,
';'
)
invoke_fsm_if
(
is_char
<
';'
>
,
read_ini_comment
(
ps
,
consumer
),
dispatch
)
transition
(
dispatch
,
'\n'
)
input
(
is_char
<
'\n'
>
,
dispatch
)
}
}
fin
();
fin
();
}
}
...
...
libcaf_core/caf/detail/parser/read_number.hpp
View file @
d4cf1f7a
...
@@ -105,35 +105,34 @@ void read_number(state<Iterator, Sentinel>& ps, Consumer& consumer) {
...
@@ -105,35 +105,34 @@ void read_number(state<Iterator, Sentinel>& ps, Consumer& consumer) {
// Definition of our parser FSM.
// Definition of our parser FSM.
start
();
start
();
state
(
init
)
{
state
(
init
)
{
input
(
is_char
<
' '
>
,
init
)
transition
(
init
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
init
)
transition
(
has_plus
,
'+'
)
input
(
is_char
<
'+'
>
,
has_plus
)
transition
(
has_minus
,
'-'
)
input
(
is_char
<
'-'
>
,
has_minus
)
transition
(
pos_zero
,
'0'
)
input
(
is_char
<
'0'
>
,
pos_zero
)
epsilon
(
has_plus
)
epsilon
(
has_plus
)
}
}
// "+" or "-" alone aren't numbers.
// "+" or "-" alone aren't numbers.
state
(
has_plus
)
{
state
(
has_plus
)
{
action
(
is_char
<
'.'
>
,
leading_dot
,
ch_res
(
positive_double
))
transition
(
leading_dot
,
'.'
,
ch_res
(
positive_double
))
input
(
is_char
<
'0'
>
,
pos_zero
)
transition
(
pos_zero
,
'0'
)
epsilon
(
pos_dec
)
epsilon
(
pos_dec
)
}
}
state
(
has_minus
)
{
state
(
has_minus
)
{
action
(
is_char
<
'.'
>
,
leading_dot
,
ch_res
(
negative_double
))
transition
(
leading_dot
,
'.'
,
ch_res
(
negative_double
))
input
(
is_char
<
'0'
>
,
neg_zero
)
transition
(
neg_zero
,
'0'
)
epsilon
(
neg_dec
)
epsilon
(
neg_dec
)
}
}
// Disambiguate base.
// Disambiguate base.
term_state
(
pos_zero
)
{
term_state
(
pos_zero
)
{
input
(
is_ichar
<
'b'
>
,
start_pos_bin
)
transition
(
start_pos_bin
,
"bB"
)
input
(
is_ichar
<
'x'
>
,
start_pos_hex
)
transition
(
start_pos_hex
,
"xX"
)
action
(
is_char
<
'.'
>
,
trailing_dot
,
ch_res
(
positive_double
))
transition
(
trailing_dot
,
'.'
,
ch_res
(
positive_double
))
epsilon
(
pos_oct
)
epsilon
(
pos_oct
)
}
}
term_state
(
neg_zero
)
{
term_state
(
neg_zero
)
{
input
(
is_ichar
<
'b'
>
,
start_neg_bin
)
transition
(
start_neg_bin
,
"bB"
)
input
(
is_ichar
<
'x'
>
,
start_neg_hex
)
transition
(
start_neg_hex
,
"xX"
)
action
(
is_char
<
'.'
>
,
trailing_dot
,
ch_res
(
negative_double
))
transition
(
trailing_dot
,
'.'
,
ch_res
(
negative_double
))
epsilon
(
neg_oct
)
epsilon
(
neg_oct
)
}
}
// Binary integers.
// Binary integers.
...
@@ -141,102 +140,96 @@ void read_number(state<Iterator, Sentinel>& ps, Consumer& consumer) {
...
@@ -141,102 +140,96 @@ void read_number(state<Iterator, Sentinel>& ps, Consumer& consumer) {
epsilon
(
pos_bin
)
epsilon
(
pos_bin
)
}
}
term_state
(
pos_bin
)
{
term_state
(
pos_bin
)
{
checked_action
(
is_digit
<
2
>
,
pos_bin
,
add_ascii
<
2
>
(
int_res
,
ch
),
transition
(
pos_bin
,
"01"
,
add_ascii
<
2
>
(
int_res
,
ch
),
ec
::
integer_overflow
)
ec
::
integer_overflow
)
}
}
state
(
start_neg_bin
)
{
state
(
start_neg_bin
)
{
epsilon
(
neg_bin
)
epsilon
(
neg_bin
)
}
}
term_state
(
neg_bin
)
{
term_state
(
neg_bin
)
{
checked_action
(
is_digit
<
2
>
,
neg_bin
,
sub_ascii
<
2
>
(
int_res
,
ch
),
transition
(
neg_bin
,
"01"
,
sub_ascii
<
2
>
(
int_res
,
ch
),
ec
::
integer_underflow
)
ec
::
integer_underflow
)
}
}
// Octal integers.
// Octal integers.
state
(
start_pos_oct
)
{
state
(
start_pos_oct
)
{
epsilon
(
pos_oct
)
epsilon
(
pos_oct
)
}
}
term_state
(
pos_oct
)
{
term_state
(
pos_oct
)
{
checked_action
(
is_digit
<
8
>
,
pos_oct
,
add_ascii
<
8
>
(
int_res
,
ch
),
transition
(
pos_oct
,
octal_chars
,
add_ascii
<
8
>
(
int_res
,
ch
),
ec
::
integer_overflow
)
ec
::
integer_overflow
)
}
}
state
(
start_neg_oct
)
{
state
(
start_neg_oct
)
{
epsilon
(
neg_oct
)
epsilon
(
neg_oct
)
}
}
term_state
(
neg_oct
)
{
term_state
(
neg_oct
)
{
checked_action
(
is_digit
<
8
>
,
neg_oct
,
sub_ascii
<
8
>
(
int_res
,
ch
),
transition
(
neg_oct
,
octal_chars
,
sub_ascii
<
8
>
(
int_res
,
ch
),
ec
::
integer_underflow
)
ec
::
integer_underflow
)
}
}
// Hexal integers.
// Hexal integers.
state
(
start_pos_hex
)
{
state
(
start_pos_hex
)
{
epsilon
(
pos_hex
)
epsilon
(
pos_hex
)
}
}
term_state
(
pos_hex
)
{
term_state
(
pos_hex
)
{
checked_action
(
is_digit
<
16
>
,
pos_hex
,
add_ascii
<
16
>
(
int_res
,
ch
),
transition
(
pos_hex
,
hexadecimal_chars
,
add_ascii
<
16
>
(
int_res
,
ch
),
ec
::
integer_overflow
)
ec
::
integer_overflow
)
}
}
state
(
start_neg_hex
)
{
state
(
start_neg_hex
)
{
epsilon
(
neg_hex
)
epsilon
(
neg_hex
)
}
}
term_state
(
neg_hex
)
{
term_state
(
neg_hex
)
{
checked_action
(
is_digit
<
16
>
,
neg_hex
,
sub_ascii
<
16
>
(
int_res
,
ch
),
transition
(
neg_hex
,
hexadecimal_chars
,
sub_ascii
<
16
>
(
int_res
,
ch
),
ec
::
integer_underflow
)
ec
::
integer_underflow
)
}
}
// Reads the integer part of the mantissa or a positive decimal integer.
// Reads the integer part of the mantissa or a positive decimal integer.
term_state
(
pos_dec
)
{
term_state
(
pos_dec
)
{
checked_action
(
is_digit
<
10
>
,
pos_dec
,
add_ascii
<
10
>
(
int_res
,
ch
),
transition
(
pos_dec
,
decimal_chars
,
add_ascii
<
10
>
(
int_res
,
ch
),
ec
::
integer_overflow
)
ec
::
integer_overflow
)
action
(
is_ichar
<
'e'
>
,
has_e
,
ch_res
(
positive_double
))
transition
(
has_e
,
"eE"
,
ch_res
(
positive_double
))
action
(
is_char
<
'.'
>
,
trailing_dot
,
ch_res
(
positive_double
))
transition
(
trailing_dot
,
'.'
,
ch_res
(
positive_double
))
}
}
// Reads the integer part of the mantissa or a negative decimal integer.
// Reads the integer part of the mantissa or a negative decimal integer.
term_state
(
neg_dec
)
{
term_state
(
neg_dec
)
{
checked_action
(
is_digit
<
10
>
,
neg_dec
,
sub_ascii
<
10
>
(
int_res
,
ch
),
transition
(
neg_dec
,
decimal_chars
,
sub_ascii
<
10
>
(
int_res
,
ch
),
ec
::
integer_underflow
)
ec
::
integer_underflow
)
action
(
is_ichar
<
'e'
>
,
has_e
,
ch_res
(
negative_double
))
transition
(
has_e
,
"eE"
,
ch_res
(
negative_double
))
action
(
is_char
<
'.'
>
,
trailing_dot
,
ch_res
(
negative_double
))
transition
(
trailing_dot
,
'.'
,
ch_res
(
negative_double
))
}
}
// ".", "+.", etc. aren't valid numbers, so this state isn't terminal.
// ".", "+.", etc. aren't valid numbers, so this state isn't terminal.
state
(
leading_dot
)
{
state
(
leading_dot
)
{
checked_action
(
is_digit
<
10
>
,
after_dot
,
rd_decimal
(
ch
),
transition
(
after_dot
,
decimal_chars
,
rd_decimal
(
ch
),
ec
::
exponent_underflow
)
ec
::
exponent_underflow
)
}
}
// "1." is a valid number, so a trailing dot is a terminal state.
// "1." is a valid number, so a trailing dot is a terminal state.
term_state
(
trailing_dot
)
{
term_state
(
trailing_dot
)
{
checked_action
(
is_digit
<
10
>
,
after_dot
,
rd_decimal
(
ch
),
epsilon
(
after_dot
)
ec
::
exponent_underflow
)
input
(
is_ichar
<
'e'
>
,
has_e
)
}
}
// Read the decimal part of a mantissa.
// Read the decimal part of a mantissa.
term_state
(
after_dot
)
{
term_state
(
after_dot
)
{
checked_action
(
is_digit
<
10
>
,
after_dot
,
rd_decimal
(
ch
),
transition
(
after_dot
,
decimal_chars
,
rd_decimal
(
ch
),
ec
::
exponent_underflow
)
ec
::
exponent_underflow
)
transition
(
has_e
,
"eE"
)
input
(
is_ichar
<
'e'
>
,
has_e
)
}
}
// "...e", "...e+", and "...e-" aren't valid numbers, so these states are not
// "...e", "...e+", and "...e-" aren't valid numbers, so these states are not
// terminal.
// terminal.
state
(
has_e
)
{
state
(
has_e
)
{
input
(
is_char
<
'+'
>
,
has_plus_after_e
)
transition
(
has_plus_after_e
,
'+'
)
input
(
is_char
<
'-'
>
,
has_minus_after_e
)
transition
(
has_minus_after_e
,
'-'
)
checked_action
(
is_digit
<
10
>
,
pos_exp
,
add_ascii
<
10
>
(
exp
,
ch
),
transition
(
pos_exp
,
decimal_chars
,
add_ascii
<
10
>
(
exp
,
ch
),
ec
::
exponent_overflow
)
ec
::
exponent_overflow
)
}
}
state
(
has_plus_after_e
)
{
state
(
has_plus_after_e
)
{
checked_action
(
is_digit
<
10
>
,
pos_exp
,
add_ascii
<
10
>
(
exp
,
ch
),
transition
(
pos_exp
,
decimal_chars
,
add_ascii
<
10
>
(
exp
,
ch
),
ec
::
exponent_overflow
)
ec
::
exponent_overflow
)
}
}
state
(
has_minus_after_e
)
{
state
(
has_minus_after_e
)
{
checked_action
(
is_digit
<
10
>
,
neg_exp
,
sub_ascii
<
10
>
(
exp
,
ch
),
transition
(
neg_exp
,
decimal_chars
,
sub_ascii
<
10
>
(
exp
,
ch
),
ec
::
exponent_underflow
)
ec
::
exponent_underflow
)
}
}
// Read a positive exponent.
// Read a positive exponent.
term_state
(
pos_exp
)
{
term_state
(
pos_exp
)
{
checked_action
(
is_digit
<
10
>
,
pos_exp
,
add_ascii
<
10
>
(
exp
,
ch
),
transition
(
pos_exp
,
decimal_chars
,
add_ascii
<
10
>
(
exp
,
ch
),
ec
::
exponent_overflow
)
ec
::
exponent_overflow
)
}
}
// Read a negative exponent.
// Read a negative exponent.
term_state
(
neg_exp
)
{
term_state
(
neg_exp
)
{
checked_action
(
is_digit
<
10
>
,
neg_exp
,
sub_ascii
<
10
>
(
exp
,
ch
),
transition
(
neg_exp
,
decimal_chars
,
sub_ascii
<
10
>
(
exp
,
ch
),
ec
::
exponent_underflow
)
ec
::
exponent_underflow
)
}
}
fin
();
fin
();
}
}
...
...
libcaf_core/caf/detail/parser/read_number_or_timespan.hpp
View file @
d4cf1f7a
...
@@ -73,36 +73,33 @@ void read_number_or_timespan(state<Iterator, Sentinel>& ps,
...
@@ -73,36 +73,33 @@ void read_number_or_timespan(state<Iterator, Sentinel>& ps,
});
});
start
();
start
();
state
(
init
)
{
state
(
init
)
{
invoke_fsm
(
read_number
(
ps
,
ic
),
has_number
)
fsm_epsilon
(
read_number
(
ps
,
ic
),
has_number
)
}
}
term_state
(
has_number
)
{
term_state
(
has_number
)
{
checked_epsilon
(
has_int
(),
has_integer
)
epsilon_if
(
has_int
(),
has_integer
)
checked_epsilon
(
has_dbl
(),
has_double
)
epsilon_if
(
has_dbl
(),
has_double
)
}
}
term_state
(
has_double
)
{
term_state
(
has_double
)
{
invalid_input
(
is_char
<
'u'
>
,
ec
::
fractional_timespan
)
error_transition
(
ec
::
fractional_timespan
,
"unms"
)
invalid_input
(
is_char
<
'n'
>
,
ec
::
fractional_timespan
)
invalid_input
(
is_char
<
'm'
>
,
ec
::
fractional_timespan
)
invalid_input
(
is_char
<
's'
>
,
ec
::
fractional_timespan
)
}
}
term_state
(
has_integer
)
{
term_state
(
has_integer
)
{
input
(
is_char
<
'u'
>
,
have_u
)
transition
(
have_u
,
'u'
)
input
(
is_char
<
'n'
>
,
have_n
)
transition
(
have_n
,
'n'
)
input
(
is_char
<
'm'
>
,
have_m
)
transition
(
have_m
,
'm'
)
action
(
is_char
<
's'
>
,
done
,
res
=
seconds
(
get_int
()))
transition
(
done
,
's'
,
res
=
seconds
(
get_int
()))
}
}
state
(
have_u
)
{
state
(
have_u
)
{
action
(
is_char
<
's'
>
,
done
,
res
=
microseconds
(
get_int
()))
transition
(
done
,
's'
,
res
=
microseconds
(
get_int
()))
}
}
state
(
have_n
)
{
state
(
have_n
)
{
action
(
is_char
<
's'
>
,
done
,
res
=
nanoseconds
(
get_int
()))
transition
(
done
,
's'
,
res
=
nanoseconds
(
get_int
()))
}
}
state
(
have_m
)
{
state
(
have_m
)
{
input
(
is_char
<
'i'
>
,
have_mi
)
transition
(
have_mi
,
'i'
)
action
(
is_char
<
's'
>
,
done
,
res
=
milliseconds
(
get_int
()))
transition
(
done
,
's'
,
res
=
milliseconds
(
get_int
()))
}
}
state
(
have_mi
)
{
state
(
have_mi
)
{
action
(
is_char
<
'n'
>
,
done
,
res
=
minutes
(
get_int
()))
transition
(
done
,
'n'
,
res
=
minutes
(
get_int
()))
}
}
term_state
(
done
)
{
term_state
(
done
)
{
// nop
// nop
...
...
libcaf_core/caf/detail/parser/read_string.hpp
View file @
d4cf1f7a
...
@@ -43,27 +43,25 @@ void read_string(state<Iterator, Sentinel>& ps, Consumer& consumer) {
...
@@ -43,27 +43,25 @@ void read_string(state<Iterator, Sentinel>& ps, Consumer& consumer) {
});
});
start
();
start
();
state
(
init
)
{
state
(
init
)
{
input
(
is_char
<
' '
>
,
init
)
transition
(
init
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
init
)
transition
(
read_chars
,
'"'
)
input
(
is_char
<
'"'
>
,
read_chars
)
}
}
state
(
read_chars
)
{
state
(
read_chars
)
{
input
(
is_char
<
'\\'
>
,
escape
)
transition
(
escape
,
'\\'
)
input
(
is_char
<
'"'
>
,
done
)
transition
(
done
,
'"'
)
invalid_input
(
is_char
<
'\n'
>
,
ec
::
unexpected_newline
)
error_transition
(
ec
::
unexpected_newline
,
'\n'
)
default_action
(
read_chars
,
res
+=
ch
)
transition
(
read_chars
,
any_char
,
res
+=
ch
)
}
}
state
(
escape
)
{
state
(
escape
)
{
action
(
is_char
<
'n'
>
,
read_chars
,
res
+=
'\n'
)
transition
(
read_chars
,
'n'
,
res
+=
'\n'
)
action
(
is_char
<
'r'
>
,
read_chars
,
res
+=
'\r'
)
transition
(
read_chars
,
'r'
,
res
+=
'\r'
)
action
(
is_char
<
't'
>
,
read_chars
,
res
+=
'\t'
)
transition
(
read_chars
,
't'
,
res
+=
'\t'
)
action
(
is_char
<
'\\'
>
,
read_chars
,
res
+=
'\\'
)
transition
(
read_chars
,
'\\'
,
res
+=
'\\'
)
action
(
is_char
<
'"'
>
,
read_chars
,
res
+=
'"'
)
transition
(
read_chars
,
'"'
,
res
+=
'"'
)
default_failure
(
ec
::
illegal_escape_sequence
)
error_transition
(
ec
::
illegal_escape_sequence
)
}
}
term_state
(
done
)
{
term_state
(
done
)
{
input
(
is_char
<
' '
>
,
done
)
transition
(
done
,
"
\t
"
)
input
(
is_char
<
'\t'
>
,
done
)
}
}
fin
();
fin
();
}
}
...
...
libcaf_core/caf/detail/pp.hpp
0 → 100644
View file @
d4cf1f7a
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2018 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#pragma once
/// Concatenates x and y into a single token.
#define CAF_PP_CAT(x, y) x ## y
/// Evaluate x and y before concatenating into a single token.
#define CAF_PP_PASTE(x, y) CAF_PP_CAT(x, y)
/// Computes the number of arguments of a variadic pack.
#define CAF_PP_SIZE(...) \
CAF_PP_SIZE_I(__VA_ARGS__, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, \
52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, \
37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, \
6, 5, 4, 3, 2, 1, )
#define CAF_PP_SIZE_I(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, \
e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, \
e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, \
e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, \
e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, \
e57, e58, e59, e60, e61, e62, e63, size, ...) \
size
/// Allows overload-like macro functions.
#define CAF_PP_OVERLOAD(PREFIX, ...) \
CAF_PP_PASTE(PREFIX, CAF_PP_SIZE(__VA_ARGS__))
libcaf_core/src/fsm.cpp
0 → 100644
View file @
d4cf1f7a
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2018 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/detail/parser/fsm.hpp"
namespace
caf
{
namespace
detail
{
const
char
alphanumeric_chars
[
63
]
=
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
;
const
char
alphabetic_chars
[
53
]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
;
const
char
hexadecimal_chars
[
23
]
=
"0123456789ABCDEFabcdef"
;
const
char
decimal_chars
[
11
]
=
"0123456789"
;
const
char
octal_chars
[
9
]
=
"01234567"
;
}
// namespace detail
}
// namespace caf
libcaf_core/test/read_bool.cpp
View file @
d4cf1f7a
...
@@ -64,19 +64,7 @@ CAF_TEST_FIXTURE_SCOPE(read_bool_tests, fixture)
...
@@ -64,19 +64,7 @@ CAF_TEST_FIXTURE_SCOPE(read_bool_tests, fixture)
CAF_TEST
(
valid
booleans
)
{
CAF_TEST
(
valid
booleans
)
{
CAF_CHECK_EQUAL
(
p
(
"true"
),
true
);
CAF_CHECK_EQUAL
(
p
(
"true"
),
true
);
CAF_CHECK_EQUAL
(
p
(
" true"
),
true
);
CAF_CHECK_EQUAL
(
p
(
" true"
),
true
);
CAF_CHECK_EQUAL
(
p
(
"true "
),
true
);
CAF_CHECK_EQUAL
(
p
(
"true "
),
true
);
CAF_CHECK_EQUAL
(
p
(
" true "
),
true
);
CAF_CHECK_EQUAL
(
p
(
"
\t
true
\t\t\t
"
),
true
);
CAF_CHECK_EQUAL
(
p
(
"false"
),
false
);
CAF_CHECK_EQUAL
(
p
(
"false"
),
false
);
CAF_CHECK_EQUAL
(
p
(
" false"
),
false
);
CAF_CHECK_EQUAL
(
p
(
" false"
),
false
);
CAF_CHECK_EQUAL
(
p
(
"false "
),
false
);
CAF_CHECK_EQUAL
(
p
(
"false "
),
false
);
CAF_CHECK_EQUAL
(
p
(
" false "
),
false
);
CAF_CHECK_EQUAL
(
p
(
"
\t
false
\t\t\t
"
),
false
);
}
}
CAF_TEST
(
invalid
booleans
)
{
CAF_TEST
(
invalid
booleans
)
{
...
@@ -84,10 +72,12 @@ CAF_TEST(invalid booleans) {
...
@@ -84,10 +72,12 @@ CAF_TEST(invalid booleans) {
CAF_CHECK_EQUAL
(
p
(
"t"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"t"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"tr"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"tr"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"tru"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"tru"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
" true"
),
ec
::
unexpected_character
);
CAF_CHECK_EQUAL
(
p
(
"f"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"f"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"fa"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"fa"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"fal"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"fal"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"fals"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
"fals"
),
ec
::
unexpected_eof
);
CAF_CHECK_EQUAL
(
p
(
" false"
),
ec
::
unexpected_character
);
CAF_CHECK_EQUAL
(
p
(
"tr
\n
ue"
),
ec
::
unexpected_newline
);
CAF_CHECK_EQUAL
(
p
(
"tr
\n
ue"
),
ec
::
unexpected_newline
);
CAF_CHECK_EQUAL
(
p
(
"trues"
),
ec
::
trailing_character
);
CAF_CHECK_EQUAL
(
p
(
"trues"
),
ec
::
trailing_character
);
}
}
...
...
libcaf_core/test/read_ini.cpp
View file @
d4cf1f7a
...
@@ -66,6 +66,16 @@ struct test_consumer {
...
@@ -66,6 +66,16 @@ struct test_consumer {
}
}
};
};
struct
ini_consumer
{
using
inner_map
=
std
::
map
<
std
::
string
,
config_value
>
;
using
section_map
=
std
::
map
<
std
::
string
,
inner_map
>
;
section_map
sections
;
section_map
::
iterator
current_section
;
};
struct
fixture
{
struct
fixture
{
expected
<
log_type
>
parse
(
std
::
string
str
,
bool
expect_success
=
true
)
{
expected
<
log_type
>
parse
(
std
::
string
str
,
bool
expect_success
=
true
)
{
detail
::
parser
::
state
<
std
::
string
::
iterator
>
res
;
detail
::
parser
::
state
<
std
::
string
::
iterator
>
res
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment