Skip to content

Commit 55bc2f7

Browse files
committed
Definition of some keywords as variables and additional binary dialect (bincode) keywords.
Object declaration has own scope now.
1 parent 59d708f commit 55bc2f7

File tree

3 files changed

+56
-13
lines changed

3 files changed

+56
-13
lines changed

Rebol.sublime-color-scheme

+14-4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@
115115
"scope": "entity.tag",
116116
"foreground": "var(tag)",
117117
},
118+
{
119+
"name": "Tags (Rebol only)",
120+
"scope": "entity.tag.rebol",
121+
"foreground": "var(tag)",
122+
"background": "var(white4)",
123+
},
118124
{
119125
"name": "Storage",
120126
"scope": "storage",
@@ -434,7 +440,7 @@
434440
},
435441
{
436442
"name": "entity.name.function",
437-
"scope": "entity.name.function",
443+
"scope": "entity.name.function, entity.name.class.rebol",
438444
"foreground": "#a62f00",
439445
"background": "#FFE9D1",
440446
"font_style": "bold",
@@ -659,12 +665,11 @@
659665
},
660666
*/
661667
{
662-
"name": "storage.type.function",
663-
"scope": "storage.type.function",
668+
"name": "Function and Rebol object declaration",
669+
"scope": "storage.type.function, storage.type.class.rebol",
664670
"foreground": "color(var(function) blend(#000 70%))",
665671
"font_style": "bold italic",
666672
},
667-
668673
{
669674
"name": "storage.type.issue",
670675
"scope": "storage.type.issue",
@@ -803,6 +808,11 @@
803808
"scope": "string.unquoted.cdata",
804809
"foreground": "var(comment)",
805810
},
811+
{
812+
"name": "HTML tag attribute",
813+
"scope": "meta.attribute-with-value.html string.quoted",
814+
"foreground": "var(string3)",
815+
},
806816

807817
]
808818
}

Rebol.sublime-syntax

+37-8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ variables:
2525
lit_word_chars: '[{{lit_word_start_chars}}]{{any_word_chars}}'
2626
refinement_chars: '{{any_word_chars}}'
2727
word_boundary: (?![^{{non_ident_chars}}])
28+
words_control_conditional: (if|either|unless|case|switch)
29+
words_control_loop: (foreach|forall|forskip|for|until|while)
30+
words_control_flow: (break|return|exit|quit|halt|continue)
31+
words_other_output: (prin(tf?)?|probe|\?\?|\?)
2832

2933
first_line_match: '^\s*(?i)(Rebol|Red)\s\['
3034
scope: source.rebol
@@ -462,6 +466,7 @@ contexts:
462466
captures:
463467
2: invalid.illegal.rebol
464468
- include: match-decl-function
469+
- include: match-decl-object
465470
- match: '({{ident}})(:){{word_boundary}}'
466471
captures:
467472
1: entity.name.word.set.rebol
@@ -490,26 +495,43 @@ contexts:
490495
2: entity.name.word.refinement.rebol
491496

492497
match-keywords:
493-
- match: '(?i)(if|either|unless|case|switch){{word_boundary}}'
498+
- match: '(?i){{words_control_conditional}}{{word_boundary}}'
494499
scope: keyword.control.conditional.rebol
495-
- match: '(?i)(foreach|forall|forskip|for|until|while){{word_boundary}}'
500+
- match: '(?i){{words_control_loop}}{{word_boundary}}'
496501
scope: keyword.control.loop.rebol
497-
- match: '(?i)(break|return|exit|quit|halt|continue){{word_boundary}}'
502+
- match: '(?i){{words_control_flow}}{{word_boundary}}'
498503
scope: keyword.control.flow.rebol
499-
- match: '(?i)(print|prin|probe|\?\?|\?){{word_boundary}}'
504+
- match: '(?i){{words_other_output}}{{word_boundary}}'
500505
scope: keyword.other.output.rebol
501506
- match: '(?i)(==|!=|<=|>=|<>|<|>|=){{word_boundary}}'
502507
scope: keyword.operator.comparison.rebol
503508
- match: '(?i)(all|any|not){{word_boundary}}'
504509
scope: keyword.operator.logical.rebol
505-
- 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}}'
506-
scope: storage.type.datatype.bincode.rebol
507-
- match: '(BIT|SB|UB|INDEX|FIXED8|BYTES){{word_boundary}}'
508-
scope: storage.type.datatype.bincode.rebol
509510
- match: '(\+\+|--){{word_boundary}}'
510511
scope: keyword.operator.assignment.augmented.rebol
512+
- include: match-keyword-bincode
511513
- include: match-keyword-tests
512514

515+
# Binary dialect (bincode) keywords:
516+
match-keyword-bincode:
517+
- 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}}'
518+
scope: storage.type.datatype.bincode.integers.rebol
519+
- match: '(?i)(float(16)?|double|fixed(8|16)){{word_boundary}}'
520+
scope: storage.type.datatype.bincode.decimals.rebol
521+
# words bellow are case sensitive by design (not to colorize any such a word if it's not fully uppercase)
522+
- match: '(BITSET(8|16|32)|BIT|(S|U|F)B){{word_boundary}}'
523+
scope: storage.type.datatype.bincode.bits.rebol
524+
- match: '(INDEX(?i)(z)?||LENGTH\?){{word_boundary}}'
525+
scope: storage.type.datatype.bincode.index-length.rebol
526+
- match: '(UNIXTIME-NOW(-LE|-BE)?|MSDOS-(TIME|DATETIME|DATE)){{word_boundary}}'
527+
scope: storage.type.datatype.bincode.rebol
528+
- match: '((STRING-|OCTAL-)?BYTES){{word_boundary}}'
529+
scope: storage.type.datatype.bincode.bytes.rebol
530+
- match: 'TUPLE(3|4){{word_boundary}}'
531+
scope: storage.type.datatype.bincode.typle.rebol
532+
- match: '(SKIP(BITS)?|ALIGN|AT(?i)(z)?){{word_boundary}}'
533+
scope: storage.type.datatype.bincode.rebol
534+
513535
# these are special function names used in unit tests
514536
match-keyword-tests:
515537
- match: (~~~(start|end)-file~~~){{word_boundary}}
@@ -553,6 +575,13 @@ contexts:
553575
# - pop-block
554576
# - pop-locals
555577
# - pop-params
578+
match-decl-object:
579+
- match: ({{ident}})(:)\s*(object|context)(?![^{{non_ident_chars}}])
580+
captures:
581+
1: entity.name.class.rebol
582+
2: keyword.operator.assignment.rebol
583+
3: storage.type.class.rebol
584+
556585

557586
match-punctuation:
558587
- include: match-slash

test.reb

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ comment 1
2828

2929
value
3030

31-
a: func [
31+
my-ctx: context [
32+
f1: does []
3233
]
34+
3335
myfunc: does [
3436
foo: 1
3537
noo: 2
@@ -304,7 +306,9 @@ a/:a:
304306
all{}
305307
{}all
306308

309+
prin now
307310
print now
311+
printf now
308312

309313
0e-0 0E-0 0.0e-0 0.0E-0 123.456e-789
310314

0 commit comments

Comments
 (0)