Fix certain identifier characters not being parsed correctly (#4522)
This commit is contained in:
parent
6e9d04d4d7
commit
63bc5fa1db
2 changed files with 41 additions and 8 deletions
|
@ -1,6 +1,9 @@
|
|||
use nom::AsBytes;
|
||||
|
||||
use crate::{sql, syn::parser::mac::test_parse};
|
||||
use crate::{
|
||||
sql::{self, Id, Statement, Thing, Value},
|
||||
syn::parser::mac::test_parse,
|
||||
};
|
||||
|
||||
mod limit;
|
||||
mod stmt;
|
||||
|
@ -14,6 +17,37 @@ fn multiple_semicolons() {
|
|||
assert_eq!(res, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn glued_identifiers() {
|
||||
let res = test_parse!(parse_query, r#"T:1"#).unwrap();
|
||||
let expected = sql::Query(sql::Statements(vec![Statement::Value(Value::Thing(Thing {
|
||||
tb: "T".to_string(),
|
||||
id: Id::Number(1),
|
||||
}))]));
|
||||
assert_eq!(res, expected);
|
||||
|
||||
let res = test_parse!(parse_query, r#"T9T9T9T:1"#).unwrap();
|
||||
let expected = sql::Query(sql::Statements(vec![Statement::Value(Value::Thing(Thing {
|
||||
tb: "T9T9T9T".to_string(),
|
||||
id: Id::Number(1),
|
||||
}))]));
|
||||
assert_eq!(res, expected);
|
||||
|
||||
let res = test_parse!(parse_query, r#"Z:1"#).unwrap();
|
||||
let expected = sql::Query(sql::Statements(vec![Statement::Value(Value::Thing(Thing {
|
||||
tb: "Z".to_string(),
|
||||
id: Id::Number(1),
|
||||
}))]));
|
||||
assert_eq!(res, expected);
|
||||
|
||||
let res = test_parse!(parse_query, r#"Z9Z9Z9Z:1"#).unwrap();
|
||||
let expected = sql::Query(sql::Statements(vec![Statement::Value(Value::Thing(Thing {
|
||||
tb: "Z9Z9Z9Z".to_string(),
|
||||
id: Id::Number(1),
|
||||
}))]));
|
||||
assert_eq!(res, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escaped_params() {
|
||||
let src = r#"LET $⟨R-_fYU8Wa31kg7tz0JI6Kme⟩ = 5;
|
||||
|
|
|
@ -128,6 +128,11 @@ impl Parser<'_> {
|
|||
|
||||
self.span_str(start.span).to_owned()
|
||||
}
|
||||
TokenKind::DatetimeChars(_) => {
|
||||
self.pop_peek();
|
||||
|
||||
self.span_str(start.span).to_owned()
|
||||
}
|
||||
_ => return Ok(start),
|
||||
};
|
||||
|
||||
|
@ -168,7 +173,7 @@ impl Parser<'_> {
|
|||
break;
|
||||
}
|
||||
// These tokens might have some more parts following them
|
||||
TokenKind::Exponent => {
|
||||
TokenKind::Exponent | TokenKind::DatetimeChars(_) | TokenKind::Digits => {
|
||||
self.pop_peek();
|
||||
let str = self.span_str(p.span);
|
||||
token_buffer.push_str(str);
|
||||
|
@ -183,12 +188,6 @@ impl Parser<'_> {
|
|||
token_buffer.push_str(suffix.as_str());
|
||||
prev = p;
|
||||
}
|
||||
TokenKind::Digits => {
|
||||
self.pop_peek();
|
||||
let str = self.span_str(p.span);
|
||||
token_buffer.push_str(str);
|
||||
prev = p;
|
||||
}
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue