Code cleanup and refactor.
This commit is contained in:
@@ -64,8 +64,8 @@ impl Engine {
|
||||
|
||||
let (stream, tokenizer_control) = self.lex_raw(
|
||||
&scripts,
|
||||
if has_null {
|
||||
Some(&|token, _, _| {
|
||||
Some(if has_null {
|
||||
&|token, _, _| {
|
||||
match token {
|
||||
// `null` => `()`
|
||||
Token::Reserved(s) if &*s == "null" => Token::Unit,
|
||||
@@ -86,9 +86,9 @@ impl Engine {
|
||||
// All others
|
||||
_ => token,
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
Some(&|token, _, _| {
|
||||
&|token, _, _| {
|
||||
match token {
|
||||
Token::Reserved(s) if &*s == "null" => Token::LexError(
|
||||
LexError::ImproperSymbol("null".to_string(), String::new()).into(),
|
||||
@@ -97,24 +97,21 @@ impl Engine {
|
||||
Token::LeftBrace => Token::MapStart,
|
||||
// Disallowed syntax
|
||||
t @ (Token::Unit | Token::MapStart) => Token::LexError(
|
||||
LexError::ImproperSymbol(
|
||||
t.literal_syntax().to_string(),
|
||||
"Invalid JSON syntax".to_string(),
|
||||
)
|
||||
.into(),
|
||||
LexError::ImproperSymbol(t.literal_syntax().to_string(), String::new())
|
||||
.into(),
|
||||
),
|
||||
Token::InterpolatedString(..) => Token::LexError(
|
||||
LexError::ImproperSymbol(
|
||||
"interpolated string".to_string(),
|
||||
"Invalid JSON syntax".to_string(),
|
||||
String::new(),
|
||||
)
|
||||
.into(),
|
||||
),
|
||||
// All others
|
||||
_ => token,
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
let ast = {
|
||||
|
Reference in New Issue
Block a user