From 18ad57fda200b071a7235878001d557c32b6c8b8 Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Sun, 18 Feb 2024 12:24:32 +0100 Subject: [PATCH] specialization and highlight fixes --- src/surrealql.ts | 6 +++--- src/tokens.ts | 2 ++ test.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/surrealql.ts b/src/surrealql.ts index e741c7b..841aa4e 100644 --- a/src/surrealql.ts +++ b/src/surrealql.ts @@ -17,8 +17,8 @@ export let parser = baseParser.configure({ Statement: continuedIndent() }), styleTags({ - "StringPrefix as asc desc collate numeric": t.keyword, - "select from where group by having order limit return transaction begin break cancel commit continue use db ns sleep show changes for table since info namespace database scope table value at with noindex index only omit split start timeout parallel explain full in": t.keyword, + "StringPrefix As Asc Desc Collate Numeric": t.keyword, + "Select From Where Group By Having Order Limit Return Transaction Begin Break Cancel Commit Continue Use Db Ns Sleep Show Changes For Table Since Info Namespace Database Scope Table Value At With Noindex Index Only Omit Split Start Timeout Parallel Explain Full In": t.keyword, Escape: t.escape, Bool: t.bool, "DivideOrMultiply AddOrSubtract": t.arithmeticOperator, @@ -34,7 +34,7 @@ export let parser = baseParser.configure({ BlockComment: t.blockComment, String: t.string, Constant: t.constant(t.variableName), - "return break ForStatement/for if else then": t.controlKeyword, + "Return Break ForStatement/For If Else Then": t.controlKeyword, "DurationUnit": t.unit, "None Null": t.null, "RecordID": t.special(t.variableName), diff --git a/src/tokens.ts b/src/tokens.ts index d74e58d..d87ec3a 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -260,12 +260,14 @@ export const tokens = new ExternalTokenizer((input, stack) => { }, {contextual: false}) export const specializeIdent = (text, stack) => { + text = text.toLowerCase() if(specmap.has(text)) { return specmap.get(text) } return -1 } export const extendIdent = (text, stack) => { + text = text.toLowerCase() if(cspecmap.has(text)) { return cspecmap.get(text) } diff --git a/test.js b/test.js index ea06284..ceaaccc 100644 --- a/test.js +++ b/test.js @@ -1,4 +1,4 @@ import {baseParser} from "./dist/index.js" console.log(baseParser.parse('select field from type::table($var) where $var > 1 and field2 @1@ field1 timeout 10s').toString()) console.log(baseParser.parse('select * from documents where contents @@ "test"').toString()) -console.log(baseParser.parse('select * from documents where test > 1').toString()) \ No newline at end of file +console.log(baseParser.parse('SELECT * FROM documents').toString()) \ No newline at end of file