ptx_parser/parser/instruction/
setmaxnreg.rs1#![allow(unused)]
7
8use crate::lexer::PtxToken;
9use crate::parser::{PtxParseError, PtxParser, PtxTokenStream, Span};
10use crate::r#type::common::*;
11
12pub mod section_0 {
13 use super::*;
14 use crate::r#type::instruction::setmaxnreg::section_0::*;
15
16 impl PtxParser for Action {
21 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
22 {
24 let saved_pos = stream.position();
25 if stream.expect_string(".inc").is_ok() {
26 return Ok(Action::Inc);
27 }
28 stream.set_position(saved_pos);
29 }
30 let saved_pos = stream.position();
31 {
33 let saved_pos = stream.position();
34 if stream.expect_string(".dec").is_ok() {
35 return Ok(Action::Dec);
36 }
37 stream.set_position(saved_pos);
38 }
39 stream.set_position(saved_pos);
40 let span = stream.peek().map(|(_, s)| s.clone()).unwrap_or(Span { start: 0, end: 0 });
41 let expected = &[".inc", ".dec"];
42 let found = stream.peek().map(|(t, _)| format!("{:?}", t)).unwrap_or_else(|_| "<end of input>".to_string());
43 Err(crate::parser::unexpected_value(span, expected, found))
44 }
45 }
46
47 impl PtxParser for SetmaxnregActionSyncAlignedU32 {
48 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
49 stream.expect_string("setmaxnreg")?;
50 let action = Action::parse(stream)?;
51 stream.expect_complete()?;
52 stream.expect_string(".sync")?;
53 let sync = ();
54 stream.expect_complete()?;
55 stream.expect_string(".aligned")?;
56 let aligned = ();
57 stream.expect_complete()?;
58 stream.expect_string(".u32")?;
59 let u32 = ();
60 stream.expect_complete()?;
61 let imm_reg_count = GeneralOperand::parse(stream)?;
62 stream.expect_complete()?;
63 stream.expect_complete()?;
64 stream.expect(&PtxToken::Semicolon)?;
65 Ok(SetmaxnregActionSyncAlignedU32 {
66 action,
67 sync,
68 aligned,
69 u32,
70 imm_reg_count,
71 })
72 }
73 }
74
75
76}
77