ptx_parser/parser/instruction/
vote_sync.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_sync::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 VoteSyncModePred {
38 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
39 try_map(
40 seq_n!(
41 string_p("vote"),
42 string_p(".sync"),
43 Mode::parse(),
44 string_p(".pred"),
45 GeneralOperand::parse(),
46 comma_p(),
47 map(optional(exclamation_p()), |value, _| value.is_some()),
48 GeneralOperand::parse(),
49 comma_p(),
50 GeneralOperand::parse(),
51 semicolon_p()
52 ),
53 |(_, sync, mode, pred, d, _, a_op, a, _, membermask, _), span| {
54 ok!(VoteSyncModePred {
55 sync = sync,
56 mode = mode,
57 pred = pred,
58 d = d,
59 a_op = a_op,
60 a = a,
61 membermask = membermask,
62
63 })
64 },
65 )
66 }
67 }
68
69 impl PtxParser for VoteSyncBallotB32 {
70 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
71 try_map(
72 seq_n!(
73 string_p("vote"),
74 string_p(".sync"),
75 string_p(".ballot"),
76 string_p(".b32"),
77 GeneralOperand::parse(),
78 comma_p(),
79 map(optional(exclamation_p()), |value, _| value.is_some()),
80 GeneralOperand::parse(),
81 comma_p(),
82 GeneralOperand::parse(),
83 semicolon_p()
84 ),
85 |(_, sync, ballot, b32, d, _, a_op, a, _, membermask, _), span| {
86 ok!(VoteSyncBallotB32 {
87 sync = sync,
88 ballot = ballot,
89 b32 = b32,
90 d = d,
91 a_op = a_op,
92 a = a,
93 membermask = membermask,
94
95 })
96 },
97 )
98 }
99 }
100}