Simply BLT grammar specification
This commit is contained in:
parent
4312bf89f6
commit
efbcfd7f6c
@ -80,8 +80,7 @@ impl<N: Number> Election<N> {
|
||||
preferences: Vec::new(),
|
||||
};
|
||||
|
||||
let ballot_preferences = ballot_pairs.next().unwrap().into_inner();
|
||||
for preference in ballot_preferences {
|
||||
for preference in ballot_pairs {
|
||||
let preference: usize = preference.as_str().parse().unwrap();
|
||||
ballot.preferences.push(preference - 1);
|
||||
}
|
||||
@ -89,9 +88,6 @@ impl<N: Number> Election<N> {
|
||||
election.ballots.push(ballot);
|
||||
}
|
||||
|
||||
// Zero line
|
||||
main.next();
|
||||
|
||||
// Read candidates
|
||||
for _ in 0..num_candidates {
|
||||
let string = main.next().expect("Expected candidate name");
|
||||
|
@ -3,7 +3,7 @@ main = {
|
||||
~ header ~ NEWLINE*
|
||||
~ withdrawn ~ NEWLINE*
|
||||
~ ballot_list
|
||||
~ zero ~ NEWLINE*
|
||||
~ "0" ~ NEWLINE*
|
||||
~ (string ~ NEWLINE*)+
|
||||
~ EOI
|
||||
}
|
||||
@ -19,11 +19,9 @@ withdrawn_cand = @{ "-" ~ integer }
|
||||
|
||||
ballot_list = { (ballot ~ NEWLINE*)* }
|
||||
ballot = {
|
||||
number ~ ballot_preferences ~ (zero ~ NEWLINE? | NEWLINE)
|
||||
number ~ integer* ~ ("0" ~ NEWLINE? | NEWLINE)
|
||||
}
|
||||
ballot_preferences = { integer* }
|
||||
|
||||
zero = { "0" }
|
||||
integer = @{ ASCII_NONZERO_DIGIT ~ ASCII_DIGIT* }
|
||||
decimal = @{ "0." ~ ASCII_DIGIT+ | integer ~ "." ~ ASCII_DIGIT+ }
|
||||
number = { decimal | integer }
|
||||
|
Loading…
Reference in New Issue
Block a user