Post: Use choice instead of or.
This commit is contained in:
parent
d1ac752de6
commit
409a2ea78f
1 changed files with 8 additions and 4 deletions
|
@ -21,11 +21,13 @@ extern crate mentat_tx;
|
||||||
extern crate mentat_parser_utils;
|
extern crate mentat_parser_utils;
|
||||||
|
|
||||||
use combine::{
|
use combine::{
|
||||||
|
choice,
|
||||||
eof,
|
eof,
|
||||||
many,
|
many,
|
||||||
parser,
|
parser,
|
||||||
satisfy,
|
satisfy,
|
||||||
satisfy_map,
|
satisfy_map,
|
||||||
|
try,
|
||||||
Parser,
|
Parser,
|
||||||
ParseResult,
|
ParseResult,
|
||||||
};
|
};
|
||||||
|
@ -90,10 +92,12 @@ def_parser!(Tx, nested_vector, Vec<AtomOrLookupRefOrVectorOrMapNotation>, {
|
||||||
});
|
});
|
||||||
|
|
||||||
def_parser!(Tx, atom_or_lookup_ref_or_vector, AtomOrLookupRefOrVectorOrMapNotation, {
|
def_parser!(Tx, atom_or_lookup_ref_or_vector, AtomOrLookupRefOrVectorOrMapNotation, {
|
||||||
Tx::lookup_ref().map(AtomOrLookupRefOrVectorOrMapNotation::LookupRef)
|
choice::<[&mut Parser<Input = _, Output = AtomOrLookupRefOrVectorOrMapNotation>; 4], _>
|
||||||
.or(Tx::nested_vector().map(AtomOrLookupRefOrVectorOrMapNotation::Vector))
|
([&mut try(Tx::lookup_ref().map(AtomOrLookupRefOrVectorOrMapNotation::LookupRef)),
|
||||||
.or(Tx::map_notation().map(AtomOrLookupRefOrVectorOrMapNotation::MapNotation))
|
&mut Tx::nested_vector().map(AtomOrLookupRefOrVectorOrMapNotation::Vector),
|
||||||
.or(Tx::atom().map(|x| x.clone()).map(AtomOrLookupRefOrVectorOrMapNotation::Atom))
|
&mut Tx::map_notation().map(AtomOrLookupRefOrVectorOrMapNotation::MapNotation),
|
||||||
|
&mut Tx::atom().map(|x| x.clone()).map(AtomOrLookupRefOrVectorOrMapNotation::Atom)
|
||||||
|
])
|
||||||
});
|
});
|
||||||
|
|
||||||
def_matches_namespaced_keyword!(Tx, literal_db_add, "db", "add");
|
def_matches_namespaced_keyword!(Tx, literal_db_add, "db", "add");
|
||||||
|
|
Loading…
Reference in a new issue