-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgo_sub.rs
More file actions
28 lines (23 loc) · 774 Bytes
/
go_sub.rs
File metadata and controls
28 lines (23 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use rusty_pc::*;
use crate::core::name::bare_name_p;
use crate::input::StringView;
use crate::pc_specific::*;
use crate::{Keyword, ParserError, Statement};
pub fn statement_go_sub_p() -> impl Parser<StringView, Output = Statement, Error = ParserError> {
keyword_ws_p(Keyword::GoSub)
.and_keep_right(bare_name_p().or_expected("label"))
.map(Statement::GoSub)
}
pub fn statement_return_p() -> impl Parser<StringView, Output = Statement, Error = ParserError> {
keyword(Keyword::Return)
.and_keep_right(lead_ws(bare_name_p()).to_option())
.map(Statement::Return)
}
#[cfg(test)]
mod tests {
use crate::assert_parser_err;
#[test]
fn go_sub_without_label() {
assert_parser_err!("GOSUB ", expected("label"));
}
}