diff options
| author | Teddy Wing | 2018-11-03 01:55:19 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-11-03 01:55:19 +0100 |
| commit | 20675d6b78e666c9fcfdb22a003a098b117dd74e (patch) | |
| tree | 9827fb7bd841c0061c091895b57dc7b75d4dac28 | |
| parent | 7776832ec11ee7d4e62cfd2a6ad7735f323ab5bc (diff) | |
| download | dome-key-map-20675d6b78e666c9fcfdb22a003a098b117dd74e.tar.bz2 | |
parser: Remove `MapAction::parse()` etc. code from second parser pass
Revert changes from 75d52e385fa66d6e151c9baa2cf22c2223c39ff0. These are
obsolete.
Now that we parse actions right in the main parser
(7776832ec11ee7d4e62cfd2a6ad7735f323ab5bc), get rid of all code related
to the second pass parser from `Action::String`s into `Action::Map`s, as
it's obsolete.
All of this action parsing is now handled by the main `map_group()`
parser.
| -rw-r--r-- | src/ffi.rs | 1 | ||||
| -rw-r--r-- | src/parser.rs | 108 |
2 files changed, 5 insertions, 104 deletions
@@ -74,7 +74,6 @@ pub extern "C" fn dome_key_state_load_map_group(ptr: *mut State) { state.map_group = match MapGroup::parse(&state.mappings_str) { Ok(mut map_group) => { - // map_group.parse_actions(); Some(map_group) }, Err(e) => { diff --git a/src/parser.rs b/src/parser.rs index 90004ed..230709d 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -27,7 +27,7 @@ pub enum HeadphoneButton { } type Trigger = Vec<HeadphoneButton>; -#[derive(Clone, Debug)] +#[derive(Debug)] struct Character(autopilot::key::Character); impl PartialEq for Character { @@ -44,7 +44,7 @@ impl Character { } } -#[derive(Clone, Debug)] +#[derive(Debug)] struct KeyCode(autopilot::key::Code); impl PartialEq for KeyCode { @@ -61,7 +61,7 @@ impl KeyCode { } } -#[derive(Clone, Debug, PartialEq)] +#[derive(Debug, PartialEq)] enum KeyboardKey { Character(Character), KeyCode(KeyCode), @@ -69,7 +69,7 @@ enum KeyboardKey { Nop, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Debug, PartialEq)] pub struct KeyboardKeyWithModifiers { key: KeyboardKey, flags: Vec<Flag>, @@ -103,30 +103,12 @@ impl KeyboardKeyWithModifiers { } } -#[derive(Clone, Debug, PartialEq)] +#[derive(Debug, PartialEq)] pub enum Action { String(String), Map(Vec<KeyboardKeyWithModifiers>), } -impl Action { - pub fn parse( - &self, - ) -> Result<Option<Action>, CombineErrors<char, &str, SourcePosition>> { - match self { - Action::String(s) => { - let input = State::new(s.as_str()); - - action_map() - .easy_parse(input) - .map(|t| t.0) - .map(|action| Some(action)) - }, - _ => Ok(None), - } - } -} - #[repr(C)] #[derive(Debug, PartialEq)] pub enum MapKind { @@ -140,74 +122,6 @@ pub struct MapAction { pub kind: MapKind, } -impl MapAction { - // pub fn parse( - // &mut self, - // ) -> Result<(), CombineErrors<char, &str, SourcePosition>> { - // use std::mem; - // match self.kind { - // MapKind::Map => { - // // match self.action { - // // Action::String(ref s) => { - // // let input = State::new(s.as_str()); - // // - // // // match action_map() - // // // .easy_parse(input) - // // // .map(|t| t.0) - // // // { - // // // Ok(a) => Some(a), - // // // Err(e) => { - // // // error!("{}", e); - // // // - // // // None - // // // }, - // // // } - // // let parsed_action = action_map() - // // .easy_parse(input) - // // .map(|t| t.0)?; - // // - // // }, - // // _ => (), - // // }; - // - // // let yo = self.action; - // // let parsed_action = self.action.parse()?; - // let yo = self.action.clone(); - // let parsed_action = match yo { - // Action::String(s) => { - // let input = State::new(s.as_str()); - // - // action_map() - // .easy_parse(input) - // .map(|t| t.0) - // .map(|action| Some(action)) - // }, - // _ => Ok(None), - // }?; - // - // if let Some(action) = parsed_action { - // // self.action = action; - // mem::replace(&mut self.action, action); - // } - // - // // self.action = { - // // let parsed_action = self.action.parse()?; - // // - // // match parsed_action { - // // Some(a) => a, - // // None => self.action, - // // } - // // }; - // }, - // - // // Commands don't get parsed. They remain `Action::String`s. - // MapKind::Command => (), - // }; - // - // Ok(()) - // } -} - #[derive(Debug, PartialEq)] struct Map { trigger: Trigger, @@ -242,18 +156,6 @@ impl MapGroup { let input = State::new(mappings); map_group().easy_parse(input).map(|t| t.0) } - - pub fn parse_actions(&mut self) { - for map_action in self.maps.values_mut() { - // map_action.parse(); - } - - for mode in self.modes.values_mut() { - for map_action in mode.values_mut() { - // map_action.parse(); - } - } - } } /// Default headphone button mappings: |
