1#[macro_use]
4extern crate lalrpop_util;
5
6lalrpop_mod!(pub grammar);
7
8mod parser;
9pub use parser::{Error, Parser};
10
11mod ast;
12pub use ast::*;
13
14#[cfg(test)]
15mod tests {
16
17 use super::grammar;
18 use crate::ast::{Action, Command, Motion};
19
20 #[test]
21 fn basic() -> anyhow::Result<()> {
22 let res = grammar::CommandParser::new().parse("dw")?;
23 assert_eq!(
24 res,
25 Command {
26 repeat: 1,
27 action: Action::Delete(Motion::WordPunc)
28 }
29 );
30
31 let res = grammar::CommandParser::new().parse("42dw")?;
32 assert_eq!(
33 res,
34 Command {
35 repeat: 42,
36 action: Action::Delete(Motion::WordPunc)
37 }
38 );
39
40 Ok(())
41 }
42
43 #[test]
44 fn char_toggle_case() -> anyhow::Result<()> {
45 let res = grammar::CommandParser::new().parse("~")?;
46 assert_eq!(
47 res,
48 Command {
49 repeat: 1,
50 action: Action::ToggleCase
51 }
52 );
53 Ok(())
54 }
55}