about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-13 19:10:59 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-13 19:10:59 -0700
commitfc2046a176334037507f77de382abdabf2895aae (patch)
treecbe00c6f510833bc78f2369048e5a401bd79d61c
parentdfc6e268c7685e7ea5f5cdb434e62e63d2d7c915 (diff)
downloadmu-fc2046a176334037507f77de382abdabf2895aae.tar.gz
1771
-rw-r--r--global.mu14
-rw-r--r--mu.vim3
2 files changed, 16 insertions, 1 deletions
diff --git a/global.mu b/global.mu
new file mode 100644
index 00000000..839926a7
--- /dev/null
+++ b/global.mu
@@ -0,0 +1,14 @@
+# example program: creating and using global variables
+
+recipe main [
+  # allocate 5 locations for globals
+  global-space:address:array:location <- new location:type, 5:literal
+  # read to globals by using /space:global
+  1:number/space:global <- copy 3:literal
+  foo
+]
+
+recipe foo [
+  # ditto for writing to globals
+  $print 1:number/space:global
+]
diff --git a/mu.vim b/mu.vim
index fb8c0b91..c5e7eebb 100644
--- a/mu.vim
+++ b/mu.vim
@@ -45,10 +45,11 @@ highlight link muNumber Constant
 syntax match muLabel "^\s\+[^ 0-9a-zA-Z{}\[\]][^ ]*\s*$"
 syntax match muLabel %[^ ]\+:label/\?[^ ,]*%
 highlight link muLabel Constant
-syntax keyword muKeyword default-space next-ingredient ingredient | highlight link muKeyword Constant
+syntax keyword muKeyword default-space global-space next-ingredient ingredient | highlight link muKeyword Constant
 
 syntax match muDelimiter "[{}]" | highlight link muDelimiter Delimiter
 syntax match muAssign " <- \|\<raw\>" | highlight link muAssign SpecialChar
+syntax match muGlobal %[^ ]\+:global/\?[^ ,]*% | highlight link muGlobal SpecialChar
 syntax keyword muControl reply reply-if reply-unless jump jump-if jump-unless loop loop-if loop-unless break break-if break-unless current-continuation continue-from create-delimited-continuation reply-delimited-continuation | highlight muControl ctermfg=3
 " common keywords
 syntax keyword muRecipe recipe before after | highlight muRecipe ctermfg=208