From 9c7822280222afc01ad9c958cd36939fd8c0919a Mon Sep 17 00:00:00 2001 From: neauoire Date: Thu, 4 Feb 2021 18:25:49 -0800 Subject: [PATCH] Added sublime syntax --- README.md | 5 +++-- examples/core.usm | 10 ++++----- extras/usm.sublime-syntax | 45 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 extras/usm.sublime-syntax diff --git a/README.md b/README.md index c5731bf..d94bbf2 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,12 @@ cc uxn.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o uxn - `( comment )` ``` -;value ( alloc zero-page variable ) +;value ( alloc a zero-page variable ) @0010 ( start at page 1 ) -,there [ ,0a ,05 GTH ] JMC +,03 ,02 ADD ,05 EQU +,there ROT JMC :here ( when not equal ) diff --git a/examples/core.usm b/examples/core.usm index 80c7372..8390b95 100644 --- a/examples/core.usm +++ b/examples/core.usm @@ -2,15 +2,15 @@ ;var1 ;var2 -;var3 + +@0100 + +:RESET ( --- ) ,22 ,var1 STR ( store 0x22 in var1 ) ,var1 LDR ( load var2, put value on stack ) -@0100 ( store program reset after zero-page ) - -:RESET ( --- ) - BRK +BRK @c000 ( much further.. ) diff --git a/extras/usm.sublime-syntax b/extras/usm.sublime-syntax new file mode 100644 index 0000000..f1542bc --- /dev/null +++ b/extras/usm.sublime-syntax @@ -0,0 +1,45 @@ +%YAML 1.2 +--- +# See http://www.sublimetext.com/docs/3/syntax.html +name: Uxn Assembly +scopeName: usm. +fileTypes: [usm] +file_extensions: + - usm +scope: source.usm + +contexts: + prototype: + - include: comments + + main: + - include: keywords + - include: numbers + - include: strings + + numbers: + - match: '\@(\S+)\s?' + scope: punctuation.definition + pop: true + + strings: + - match: '\:(\S+)\s?' + scope: string.control + pop: true + - match: '\;(\S+)\s?' + scope: string.control + pop: true + - match: '\,(\S+)\s?' + scope: keyword.control + pop: true + - match: '\.(\S+)\s?' + scope: keyword.control + pop: true + + comments: + - match: '\(' + scope: punctuation.definition.comment.tome + push: + - meta_scope: comment.line.double-slash.tome + - match: '\)' + pop: true