ptx_parser/parser/instruction/
bra.rs

1//! Original PTX specification:
2//!
3//! bra{.uni}  tgt;           // tgt is a label
4//! bra{.uni}  tgt;           // unconditional branch
5
6#![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::bra::section_0::*;
15
16    impl PtxParser for BraUni {
17        fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
18            stream.expect_string("bra")?;
19            let saved_pos = stream.position();
20            let uni = stream.expect_string(".uni").is_ok();
21            if !uni {
22                stream.set_position(saved_pos);
23            }
24            stream.expect_complete()?;
25            let tgt = GeneralOperand::parse(stream)?;
26            stream.expect_complete()?;
27            stream.expect_complete()?;
28            stream.expect(&PtxToken::Semicolon)?;
29            Ok(BraUni {
30                uni,
31                tgt,
32            })
33        }
34    }
35
36
37    impl PtxParser for BraUni1 {
38        fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
39            stream.expect_string("bra")?;
40            let saved_pos = stream.position();
41            let uni = stream.expect_string(".uni").is_ok();
42            if !uni {
43                stream.set_position(saved_pos);
44            }
45            stream.expect_complete()?;
46            let tgt = GeneralOperand::parse(stream)?;
47            stream.expect_complete()?;
48            stream.expect_complete()?;
49            stream.expect(&PtxToken::Semicolon)?;
50            Ok(BraUni1 {
51                uni,
52                tgt,
53            })
54        }
55    }
56
57
58}
59