a few changes enclosed:
* documented deps * mild string escaping * corrected a misbehavior in sym
This commit is contained in:
parent
d7864ee628
commit
5afc2cc4a1
4 changed files with 22 additions and 14 deletions
12
src/lex.rs
12
src/lex.rs
|
|
@ -16,10 +16,18 @@
|
|||
*/
|
||||
|
||||
use crate::segment::{Ctr, Seg};
|
||||
use phf::{Map, phf_map};
|
||||
|
||||
const UNMATCHED_STR_DELIM: &str = "Unmatched string delimiter in input";
|
||||
const UNMATCHED_LIST_DELIM: &str = "Unmatched list delimiter in input";
|
||||
|
||||
|
||||
static ESCAPES: Map<char, char> = phf_map! {
|
||||
'n' => '\n',
|
||||
't' => '\t',
|
||||
'\\' => '\\',
|
||||
};
|
||||
|
||||
/* takes a line of user input
|
||||
* returns an unsimplified tree of tokens.
|
||||
*/
|
||||
|
|
@ -71,7 +79,7 @@ fn process(document: &String) -> Result<Box<Seg>, String> {
|
|||
delim = *d;
|
||||
|
||||
if delim == '*' {
|
||||
token.push(c);
|
||||
token.push(ESCAPES[&c]);
|
||||
delim_stack.pop();
|
||||
continue;
|
||||
|
||||
|
|
@ -136,7 +144,7 @@ fn process(document: &String) -> Result<Box<Seg>, String> {
|
|||
delim_stack.push('\n');
|
||||
}
|
||||
// escape next char
|
||||
'\\' => {
|
||||
'\\' => if is_str {
|
||||
delim_stack.push('*');
|
||||
}
|
||||
// add to token
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue