parser-pda
This crate provides a demo of using fi_night crate for implementation
of a simple parser capable of indexing nested bracketed segments of text.
The parser distinguishes sentences separated by '.' and [bracketed]
text
segments.
The automaton implementation can be seen in modules
parser_pda.rs and parser_nondet_pda.rs which implement two
versions providing the same functionality.
Here is an example:
use ;
use ;
use ;
use ;
The code running stores the rust code of the automaton under /target/fsm/parser_automaton.rs and emits the following output:
input: Fif[teen] men on a dead man's [[chest]]. []]Yo [[ho [[ho. And [the [bottle] ]of [[[RUM]]]
Sentence[0 39) -> Fif[teen] men on a dead man's [[chest]]
Plain[0 30) -> Fif[teen] men on a dead man's
Plain[0 3) -> Fif
Bracketed[4 8) -> teen
Bracketed[31 38) -> [chest]
Bracketed[32 37) -> chest
InvalidSentence[40 56) -> []]Yo [[ho [[ho
Plain[40 43) -> []
Plain[40 41) ->
Bracketed[42 42) ->
UnbalancedRightSth[43 56) -> ]Yo [[ho [[ho
Tail[57 90) -> And [the [bottle] ]of [[[RUM]]]
Plain[57 80) -> And [the [bottle] ]of
Plain[57 62) -> And
Bracketed[63 76) -> the [bottle]
Bracketed[68 74) -> bottle
Bracketed[81 88) -> [[RUM]]
Bracketed[82 87) -> [RUM]
Bracketed[83 86) -> RUM