Allow units with spaces by wrapping them in ""

This commit is contained in:
Tiffany Bennett 2016-10-11 12:43:58 -04:00
parent 06d280b4ae
commit 716efc2edf
3 changed files with 34 additions and 4 deletions

View file

@ -679,8 +679,8 @@ arcminute arcmin
' arcmin ' arcmin
arcsec 1|60 arcmin arcsec 1|60 arcmin
arcsecond arcsec arcsecond arcsec
" arcsec #" arcsec
'' " #'' "
rightangle 90 degrees rightangle 90 degrees
quadrant 1|4 circle quadrant 1|4 circle
quintant 1|5 circle quintant 1|5 circle
@ -5364,8 +5364,8 @@ röntgen roentgen
ħ hbar ħ hbar
‰ 1|1000 ‰ 1|1000
‱ 1|10000 ‱ 1|10000
' # U+2032 # ' # U+2032
″ " # U+2033 #″ " # U+2033
# #
# Square unicode symbols starting at U+3371 # Square unicode symbols starting at U+3371

View file

@ -156,6 +156,21 @@ impl<'a> Iterator for TokenIterator<'a> {
} }
Token::Number(integer, frac, exp) Token::Number(integer, frac, exp)
}, },
'"' => {
let mut buf = String::new();
while let Some(c) = self.0.next() {
if c == '\\' {
if let Some(c) = self.0.next() {
buf.push(c);
}
} else if c == '"' {
break;
} else {
buf.push(c);
}
}
Token::Ident(buf)
},
x if is_ident(x) => { x if is_ident(x) => {
let mut buf = String::new(); let mut buf = String::new();
buf.push(x); buf.push(x);

View file

@ -392,6 +392,21 @@ impl<'a> Iterator for TokenIterator<'a> {
} }
Token::Date(toks) Token::Date(toks)
}, },
'"' => {
let mut buf = String::new();
while let Some(c) = self.0.next() {
if c == '\\' {
if let Some(c) = self.0.next() {
buf.push(c);
}
} else if c == '"' {
break;
} else {
buf.push(c);
}
}
Token::Ident(buf)
},
x => { x => {
let mut buf = String::new(); let mut buf = String::new();
buf.push(x); buf.push(x);