Skip to content

Commit 1666cc0

Browse files
authored
Merge PR #393: Simplify string patterns
2 parents 2c8c15c + 7401937 commit 1666cc0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/lexer/regexFactory.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,16 @@ const buildQStringPatterns = () => {
111111
// 6. BigQuery '''triple-quoted'''
112112
// 7. BigQuery """triple-quoted"""
113113
// 8. Hive and Spark variables: ${name}
114+
// 9. Oracle q'' strings: q'<text>' q'|text|' ...
114115
export const quotePatterns = {
115116
'``': '(?:`[^`]*(?:$|`))+',
116-
'[]': '(?:\\[[^\\]]*(?:$|\\]))(?:\\][^\\]]*(?:$|\\]))*',
117-
'""': '(?:"[^"\\\\]*(?:\\\\.[^"\\\\]*)*(?:"|$))+',
118-
"''": "(?:'[^'\\\\]*(?:\\\\.[^'\\\\]*)*(?:'|$))+",
119-
'$$': '(?<tag>\\$\\w*\\$)[\\s\\S]*?(?:\\k<tag>|$)',
120-
"'''..'''": "'''[^\\\\]*?(?:\\\\.[^\\\\]*?)*?(?:'''|$)",
121-
'""".."""': '"""[^\\\\]*?(?:\\\\.[^\\\\]*?)*?(?:"""|$)',
122-
'{}': '(?:\\{[^\\}]*(?:$|\\}))',
117+
'[]': String.raw`(?:\[[^\]]*(?:$|\]))(?:\][^\]]*(?:$|\]))*`,
118+
'""': String.raw`(?:"[^"\\]*(?:\\.[^"\\]*)*(?:"|$))+`,
119+
"''": String.raw`(?:'[^'\\]*(?:\\.[^'\\]*)*(?:'|$))+`,
120+
'$$': String.raw`(?<tag>\$\w*\$)[\s\S]*?(?:\k<tag>|$)`,
121+
"'''..'''": String.raw`'''[^\\]*?(?:\\.[^\\]*?)*?(?:'''|$)`,
122+
'""".."""': String.raw`"""[^\\]*?(?:\\.[^\\]*?)*?(?:"""|$)`,
123+
'{}': String.raw`(?:\{[^\}]*(?:$|\}))`,
123124
"q''": buildQStringPatterns(),
124125
};
125126

0 commit comments

Comments
 (0)