more complex tests

This commit is contained in:
Aidan Hahn 2021-07-19 23:59:03 -07:00
parent df5cb47cb4
commit 2c30975571
No known key found for this signature in database
GPG key ID: 327711E983899316
6 changed files with 179 additions and 320 deletions

View file

@ -164,7 +164,7 @@ fn process(document: String) -> Result<Ast, String> {
} else if let Some(s) = tok_is_symbol(&token) {
obj = Ctr::Symbol(s);
} else {
return Err(format!("Unparsable token:{}", token));
return Err(format!("Unparsable token: {}", token));
}
token = String::new();
@ -195,14 +195,14 @@ fn process(document: String) -> Result<Ast, String> {
/* Returns true if token
* - is all alphanumeric
* - is all alphanumeric except dash and underscore
*
* else returns false
*/
fn tok_is_symbol(token: &String) -> Option<String> {
let tok = token.as_str();
for t in tok.chars() {
if !t.is_alphabetic() && !t.is_digit(10) {
if !t.is_alphabetic() && !t.is_digit(10) && !(t == '-') && !(t == '_') {
return None
}
}