diff --git a/partiql-parser/src/partiql.pest b/partiql-parser/src/partiql.pest index 986f117c..cf2716fe 100644 --- a/partiql-parser/src/partiql.pest +++ b/partiql-parser/src/partiql.pest @@ -155,7 +155,7 @@ StringContent = { Identifier = { NonQuotedIdentifier | QuotedIdentifier } NonQuotedIdentifier = @{ - !Keyword ~ NonQuotedIdentifierStart ~ NonQuotedIdentifierCont* + !(Keyword) ~ NonQuotedIdentifierStart ~ NonQuotedIdentifierCont* } NonQuotedIdentifierStart = _{ "_" | "$" | 'a'..'z' | 'A'..'Z' } @@ -173,7 +173,9 @@ QuotedIdentifierContent = { // Keywords // -Keyword = { SqlKeyword | PartiqlKeyword } +Keyword = @{ + (SqlKeyword | PartiqlKeyword) ~ !NonQuotedIdentifierCont +} SqlKeyword = _{ Absolute_ diff --git a/partiql-parser/src/scanner.rs b/partiql-parser/src/scanner.rs index 0b50cc6c..6492237f 100644 --- a/partiql-parser/src/scanner.rs +++ b/partiql-parser/src/scanner.rs @@ -509,7 +509,7 @@ mod test { "WHERE" => keyword("WHERE") ] )] - #[case::some_keywords( + #[case::some_identifiers( scanner_test_case![ "moo_cow_1999" => identifier("moo_cow_1999"), " ", @@ -518,6 +518,13 @@ mod test { "$$$$" => identifier("$$$$") ] )] + #[case::identifiers_with_keywords_in_them( + scanner_test_case![ + "moowhere" => identifier("moowhere"), + " ", + "selecty" => identifier("selecty"), + ] + )] #[case::quoted_identifiers( scanner_test_case![ " ",