Skip to content

Commit 16de67c

Browse files
committed
done \x in strings pretty messy
1 parent 0ac02b5 commit 16de67c

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ pub fn get_dash_args(args: &[String], start_index: usize, args_struct: &mut Pars
7575
}
7676
let num = match &args_struct.file {
7777
// TODO: use rand
78-
file if file.is_empty() => 0i32,
79-
file => file.len() as i32,
78+
file if file.is_empty() => 0,
79+
file => file.len(),
8080
};
81-
unsafe { TOGGLE_CASE = num }
81+
unsafe { TOGGLE_CASE = num.try_into().unwrap() }
8282
} else if char_part_arg == 't' {
8383
let number: i32 = match arg.split_once('=') {
8484
Some(n) => match n.1.parse() {

src/lexer.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,20 @@ impl Lexer {
164164
self.source.insert(self.current, '\x1b');
165165
self.advance();
166166
} else if self.peek() == 'X' {
167-
todo!();
167+
self.source.remove(self.current);
168+
match self.source.remove(self.current) {
169+
x if x.is_ascii_hexdigit() => match self.source.remove(self.current) {
170+
y if y.is_ascii_hexdigit() => {self.source.insert(self.current, u8::from_str_radix(format!("{x}{y}").as_str(), 16).unwrap() as char);
171+
self.advance();},
172+
y => {self.source.insert(self.current, u8::from_str_radix(format!("{x}").as_str(), 16).unwrap() as char);
173+
self.source.insert(self.current+1, y);
174+
self.advance();}
175+
},
176+
x => {self.source.insert(self.current, x);
177+
self.advance();
178+
}
179+
};
180+
168181
} else if self.peek() == 'O' {
169182
todo!();
170183
} else if self.peek() == 'U' {

umpl_examples/simple.umpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ create str with ((multiply `ff\n` 5.76))>
1313
(4)>>
1414
create str with `df`
1515
(str)>
16-
(`fdff\a `)>
16+
(`fdff\X4\n`)>
1717
((multiplywith str 5))<
1818
(str)>>
1919
((addwith str 5))<

0 commit comments

Comments
 (0)