| 77 | } |
| 78 | |
| 79 | fn parse_modifier_sequence(&mut self, meta: &mut ParserMetadata) -> SyntaxResult { |
| 80 | loop { |
| 81 | match meta.get_current_token() { |
| 82 | Some(tok) => match tok.word.as_str() { |
| 83 | trust @ ("trust" | "unsafe") => { |
| 84 | if trust == "unsafe" { |
| 85 | let message = Message::new_warn_at_token(meta, Some(tok.clone())) |
| 86 | .message("The keyword `unsafe` has been deprecated in favor of `trust`.") |
| 87 | .comment("Learn more about this change: https://docs.amber-lang.com/basic_syntax/commands#command-modifiers"); |
| 88 | meta.add_message(message); |
| 89 | } |
| 90 | if self.is_trust { |
| 91 | return error!( |
| 92 | meta, |
| 93 | Some(tok.clone()), |
| 94 | "You already declared `trust` modifier before" |
| 95 | ); |
| 96 | } |
| 97 | self.is_trust = true; |
| 98 | self.trust_position = |
| 99 | Some(PositionInfo::from_token(meta, Some(tok.clone()))); |
| 100 | meta.increment_index(); |
| 101 | } |
| 102 | "silent" => { |
| 103 | if self.is_silent { |
| 104 | return error!( |
| 105 | meta, |
| 106 | Some(tok.clone()), |
| 107 | "You already declared `silent` modifier before" |
| 108 | ); |
| 109 | } |
| 110 | if self.is_suppress { |
| 111 | return error!(meta, Some(tok.clone()), "You already declared `suppress` modifier before. You can't use them in conjunction."); |
| 112 | } |
| 113 | self.is_silent = true; |
| 114 | self.silent_position = |
| 115 | Some(PositionInfo::from_token(meta, Some(tok.clone()))); |
| 116 | meta.increment_index(); |
| 117 | } |
| 118 | "suppress" => { |
| 119 | if self.is_silent { |
| 120 | return error!(meta, Some(tok.clone()), "You already declared `silent` modifier before. You can't use them in conjunction."); |
| 121 | } |
| 122 | if self.is_suppress { |
| 123 | return error!( |
| 124 | meta, |
| 125 | Some(tok.clone()), |
| 126 | "You already declared `suppress` modifier before" |
| 127 | ); |
| 128 | } |
| 129 | self.is_suppress = true; |
| 130 | self.suppress_position = |
| 131 | Some(PositionInfo::from_token(meta, Some(tok.clone()))); |
| 132 | meta.increment_index(); |
| 133 | } |
| 134 | "sudo" => { |
| 135 | if self.is_sudo { |
| 136 | return error!( |