ptx_parser/parser/instruction/
vote.rs1#![allow(unused)]
8
9use crate::parser::{
10 PtxParseError, PtxParser, PtxTokenStream, Span,
11 util::{
12 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
13 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
14 },
15};
16use crate::r#type::common::*;
17use crate::{alt, ok, seq_n};
18
19pub mod section_0 {
20 use super::*;
21 use crate::r#type::instruction::vote::section_0::*;
22
23 impl PtxParser for Mode {
28 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
29 alt!(
30 map(string_p(".all"), |_, _span| Mode::All),
31 map(string_p(".any"), |_, _span| Mode::Any),
32 map(string_p(".uni"), |_, _span| Mode::Uni)
33 )
34 }
35 }
36
37 impl PtxParser for VoteModePred {
38 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
39 try_map(
40 seq_n!(
41 string_p("vote"),
42 Mode::parse(),
43 string_p(".pred"),
44 GeneralOperand::parse(),
45 comma_p(),
46 map(optional(exclamation_p()), |value, _| value.is_some()),
47 GeneralOperand::parse(),
48 semicolon_p()
49 ),
50 |(_, mode, pred, d, _, a_op, a, _), span| {
51 ok!(VoteModePred {
52 mode = mode,
53 pred = pred,
54 d = d,
55 a_op = a_op,
56 a = a,
57
58 })
59 },
60 )
61 }
62 }
63
64 impl PtxParser for VoteBallotB32 {
65 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
66 try_map(
67 seq_n!(
68 string_p("vote"),
69 string_p(".ballot"),
70 string_p(".b32"),
71 GeneralOperand::parse(),
72 comma_p(),
73 map(optional(exclamation_p()), |value, _| value.is_some()),
74 GeneralOperand::parse(),
75 semicolon_p()
76 ),
77 |(_, ballot, b32, d, _, a_op, a, _), span| {
78 ok!(VoteBallotB32 {
79 ballot = ballot,
80 b32 = b32,
81 d = d,
82 a_op = a_op,
83 a = a,
84
85 })
86 },
87 )
88 }
89 }
90}