-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SQLite language configuration #116
Comments
@ericzakariasson I took the liberty to copy your code snippet into this issue for easier reference. Thank you — it looks fine to me. I propose that we wait for @barnettben's SQL configuration, and then, we can have a look together, to see whether we can share some definitions or whether they need to be entirely separate configurations. import LanguageSupport
import Foundation
import RegexBuilder
private let postgresReservedIds = [
"ALL", "ANALYSE", "ANALYZE", "AND", "ANY", "ARRAY", "AS", "ASC", "ASYMMETRIC",
"AUTHORIZATION", "BINARY", "BOTH", "CASE", "CAST", "CHECK", "COLLATE", "COLLATION",
"COLUMN", "CONCURRENTLY", "CONSTRAINT", "CREATE", "CROSS", "CURRENT_CATALOG",
"CURRENT_DATE", "CURRENT_ROLE", "CURRENT_SCHEMA", "CURRENT_TIME", "CURRENT_TIMESTAMP",
"CURRENT_USER", "DEFAULT", "DEFERRABLE", "DESC", "DISTINCT", "DO", "ELSE", "END",
"EXCEPT", "FALSE", "FETCH", "FOR", "FOREIGN", "FREEZE", "FROM", "FULL", "GRANT",
"GROUP", "HAVING", "ILIKE", "IN", "INITIALLY", "INNER", "INTERSECT", "INTO", "IS",
"ISNULL", "JOIN", "LATERAL", "LEADING", "LEFT", "LIKE", "LIMIT", "LOCALTIME",
"LOCALTIMESTAMP", "NATURAL", "NOT", "NOTNULL", "NULL", "OFFSET", "ON", "ONLY",
"OR", "ORDER", "OUTER", "OVERLAPS", "PLACING", "PRIMARY", "REFERENCES", "RETURNING",
"RIGHT", "SELECT", "SESSION_USER", "SIMILAR", "SOME", "SYMMETRIC", "TABLE", "THEN",
"TO", "TRAILING", "TRUE", "UNION", "UNIQUE", "USER", "USING", "VARIADIC", "VERBOSE",
"WHEN", "WHERE", "WINDOW", "WITH"
]
private let postgresReservedOperators = [
"+", "-", "*", "/", "%", "=", "<>", "!=", "<", ">", "<=", ">=", "||",
"<<", ">>", "&<", "&>", "<<|", "|>>", "&<|", "|&>",
"->", "->>", "#>", "#>>", "@>", "<@", "?", "?|", "?&",
"&&", "-|-", "~~", "~~*", "!~~", "!~~*", "@@@", "::", "."
]
extension LanguageConfiguration {
/// Language configuration for PostgreSQL
public static func postgres(_ languageService: LanguageService? = nil) -> LanguageConfiguration {
// numeric types
let numberRegex = /[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/
// identifiers
let identifierRegex = /[a-zA-Z_][a-zA-Z0-9_$]*|"[^"]+"/
// operators
let operatorRegex = /[+\-*\/<>=!|&%^~?#@:.]+/
// standard quotes and dollar quoting
let stringRegex = /'(?:[^']|'')*'|"(?:[^"]|"")*"|(?:\$[^$]*\$).*?/
return LanguageConfiguration(
name: "PostgreSQL",
supportsSquareBrackets: true,
supportsCurlyBrackets: false,
stringRegex: stringRegex,
characterRegex: nil,
numberRegex: numberRegex,
singleLineComment: "--",
nestedComment: (open: "/*", close: "*/"),
identifierRegex: identifierRegex,
operatorRegex: operatorRegex,
reservedIdentifiers: postgresReservedIds,
reservedOperators: postgresReservedOperators,
languageService: languageService
)
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As suggested in #112 (here), this ticket can be used to track progress of an SQL/SQLite language configuration.
I will hopefully have a go over the next week or so.
The text was updated successfully, but these errors were encountered: