Skip to content

Commit

Permalink
Definition of some keywords as variables and additional binary dialec…
Browse files Browse the repository at this point in the history
…t (bincode) keywords.

Object declaration has own scope now.
  • Loading branch information
Oldes committed Nov 24, 2020
1 parent 59d708f commit 55bc2f7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 13 deletions.
18 changes: 14 additions & 4 deletions Rebol.sublime-color-scheme
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)",
},

]
}
45 changes: 37 additions & 8 deletions Rebol.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion test.reb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ comment 1

value

a: func [
my-ctx: context [
f1: does []
]

myfunc: does [
foo: 1
noo: 2
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 55bc2f7

Please sign in to comment.