From 55bc2f74430f54767d017e5e9856d1d3fa84e02f Mon Sep 17 00:00:00 2001 From: Oldes Date: Tue, 24 Nov 2020 20:13:06 +0100 Subject: [PATCH] Definition of some keywords as variables and additional binary dialect (bincode) keywords. Object declaration has own scope now. --- Rebol.sublime-color-scheme | 18 +++++++++++---- Rebol.sublime-syntax | 45 +++++++++++++++++++++++++++++++------- test.reb | 6 ++++- 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/Rebol.sublime-color-scheme b/Rebol.sublime-color-scheme index cc6b9cd..97faf3c 100644 --- a/Rebol.sublime-color-scheme +++ b/Rebol.sublime-color-scheme @@ -115,6 +115,12 @@ "scope": "entity.tag", "foreground": "var(tag)", }, + { + "name": "Tags (Rebol only)", + "scope": "entity.tag.rebol", + "foreground": "var(tag)", + "background": "var(white4)", + }, { "name": "Storage", "scope": "storage", @@ -434,7 +440,7 @@ }, { "name": "entity.name.function", - "scope": "entity.name.function", + "scope": "entity.name.function, entity.name.class.rebol", "foreground": "#a62f00", "background": "#FFE9D1", "font_style": "bold", @@ -659,12 +665,11 @@ }, */ { - "name": "storage.type.function", - "scope": "storage.type.function", + "name": "Function and Rebol object declaration", + "scope": "storage.type.function, storage.type.class.rebol", "foreground": "color(var(function) blend(#000 70%))", "font_style": "bold italic", }, - { "name": "storage.type.issue", "scope": "storage.type.issue", @@ -803,6 +808,11 @@ "scope": "string.unquoted.cdata", "foreground": "var(comment)", }, + { + "name": "HTML tag attribute", + "scope": "meta.attribute-with-value.html string.quoted", + "foreground": "var(string3)", + }, ] } diff --git a/Rebol.sublime-syntax b/Rebol.sublime-syntax index 847b9c0..2e58898 100644 --- a/Rebol.sublime-syntax +++ b/Rebol.sublime-syntax @@ -25,6 +25,10 @@ variables: lit_word_chars: '[{{lit_word_start_chars}}]{{any_word_chars}}' refinement_chars: '{{any_word_chars}}' word_boundary: (?![^{{non_ident_chars}}]) + words_control_conditional: (if|either|unless|case|switch) + words_control_loop: (foreach|forall|forskip|for|until|while) + words_control_flow: (break|return|exit|quit|halt|continue) + words_other_output: (prin(tf?)?|probe|\?\?|\?) first_line_match: '^\s*(?i)(Rebol|Red)\s\[' scope: source.rebol @@ -462,6 +466,7 @@ contexts: captures: 2: invalid.illegal.rebol - include: match-decl-function + - include: match-decl-object - match: '({{ident}})(:){{word_boundary}}' captures: 1: entity.name.word.set.rebol @@ -490,26 +495,43 @@ contexts: 2: entity.name.word.refinement.rebol match-keywords: - - match: '(?i)(if|either|unless|case|switch){{word_boundary}}' + - match: '(?i){{words_control_conditional}}{{word_boundary}}' scope: keyword.control.conditional.rebol - - match: '(?i)(foreach|forall|forskip|for|until|while){{word_boundary}}' + - match: '(?i){{words_control_loop}}{{word_boundary}}' scope: keyword.control.loop.rebol - - match: '(?i)(break|return|exit|quit|halt|continue){{word_boundary}}' + - match: '(?i){{words_control_flow}}{{word_boundary}}' scope: keyword.control.flow.rebol - - match: '(?i)(print|prin|probe|\?\?|\?){{word_boundary}}' + - match: '(?i){{words_other_output}}{{word_boundary}}' scope: keyword.other.output.rebol - match: '(?i)(==|!=|<=|>=|<>|<|>|=){{word_boundary}}' scope: keyword.operator.comparison.rebol - match: '(?i)(all|any|not){{word_boundary}}' scope: keyword.operator.logical.rebol - - match: '(?i)(ui8(le|be|bytes)?|ui16(le|be|bytes)?|ui24(le|be|bytes)?|ui32(le|be|bytes)?|ui64(le|be|bytes)?|si8(le|be|bytes)?|si16(le|be|bytes)?|si24(le|be|bytes)?|si32(le|be|bytes)?|si64(le|be|bytes)?){{word_boundary}}' - scope: storage.type.datatype.bincode.rebol - - match: '(BIT|SB|UB|INDEX|FIXED8|BYTES){{word_boundary}}' - scope: storage.type.datatype.bincode.rebol - match: '(\+\+|--){{word_boundary}}' scope: keyword.operator.assignment.augmented.rebol + - include: match-keyword-bincode - include: match-keyword-tests + # Binary dialect (bincode) keywords: + match-keyword-bincode: + - match: '(?i)((u|s)i8(le|be|(le|be)?bytes)?|(u|s)i16(le|be|(le|be)?bytes)?|(u|s)i24(le|be|(le|be)?bytes)?|(u|s)i32(le|be|(le|be)?bytes)?|(u|s)i64(le|be|(le|be)?bytes|EncodedU32)?){{word_boundary}}' + scope: storage.type.datatype.bincode.integers.rebol + - match: '(?i)(float(16)?|double|fixed(8|16)){{word_boundary}}' + scope: storage.type.datatype.bincode.decimals.rebol + # words bellow are case sensitive by design (not to colorize any such a word if it's not fully uppercase) + - match: '(BITSET(8|16|32)|BIT|(S|U|F)B){{word_boundary}}' + scope: storage.type.datatype.bincode.bits.rebol + - match: '(INDEX(?i)(z)?||LENGTH\?){{word_boundary}}' + scope: storage.type.datatype.bincode.index-length.rebol + - match: '(UNIXTIME-NOW(-LE|-BE)?|MSDOS-(TIME|DATETIME|DATE)){{word_boundary}}' + scope: storage.type.datatype.bincode.rebol + - match: '((STRING-|OCTAL-)?BYTES){{word_boundary}}' + scope: storage.type.datatype.bincode.bytes.rebol + - match: 'TUPLE(3|4){{word_boundary}}' + scope: storage.type.datatype.bincode.typle.rebol + - match: '(SKIP(BITS)?|ALIGN|AT(?i)(z)?){{word_boundary}}' + scope: storage.type.datatype.bincode.rebol + # these are special function names used in unit tests match-keyword-tests: - match: (~~~(start|end)-file~~~){{word_boundary}} @@ -553,6 +575,13 @@ contexts: # - pop-block # - pop-locals # - pop-params + match-decl-object: + - match: ({{ident}})(:)\s*(object|context)(?![^{{non_ident_chars}}]) + captures: + 1: entity.name.class.rebol + 2: keyword.operator.assignment.rebol + 3: storage.type.class.rebol + match-punctuation: - include: match-slash diff --git a/test.reb b/test.reb index ed03a8f..cb457a7 100644 --- a/test.reb +++ b/test.reb @@ -28,8 +28,10 @@ comment 1 value -a: func [ +my-ctx: context [ + f1: does [] ] + myfunc: does [ foo: 1 noo: 2 @@ -304,7 +306,9 @@ a/:a: all{} {}all +prin now print now +printf now 0e-0 0E-0 0.0e-0 0.0E-0 123.456e-789