aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-11-12 23:08:32 +0000
committerDavid Neto <dneto@google.com>2018-11-13 17:13:13 -0500
commit5bbbd0748757bbcffbc75f800dd5ec3014b2c9c2 (patch)
treee7842a0e801ce6fc97a197881fcc0642b4150cbc
parentc55def0bfd686650de1ef33e4ed33f3aabe399f4 (diff)
downloadamber-5bbbd0748757bbcffbc75f800dd5ec3014b2c9c2.tar.gz
Add syntax files for Amber
-rw-r--r--docs/amber_script.md2
-rw-r--r--tools/amber-syntax.vim64
-rw-r--r--tools/amber.sublime-syntax65
3 files changed, 130 insertions, 1 deletions
diff --git a/docs/amber_script.md b/docs/amber_script.md
index b998377..b4d4867 100644
--- a/docs/amber_script.md
+++ b/docs/amber_script.md
@@ -107,7 +107,7 @@ Floating point data uses floating point addition to generate increasting values.
Likewise, integer data uses integer addition to generate increasing values.
```
-SERIES <start> <inc>
+SERIES_FROM <start> INC_BY <inc>
```
### Pipelines
diff --git a/tools/amber-syntax.vim b/tools/amber-syntax.vim
new file mode 100644
index 0000000..86ae2c5
--- /dev/null
+++ b/tools/amber-syntax.vim
@@ -0,0 +1,64 @@
+" Vim syntax file
+" Language: Amber Script
+
+if exists("b:current_syntax")
+ finish
+endif
+
+" Regular int like number with - + or nothing in front
+syn match amberNumber '\d\+' contained display
+syn match amberNumber '[-+]\d\+' contained display
+
+" Floating point number with decimal no E or e (+,-)
+syn match amberNumber '\d\+\.\d*' contained display
+syn match amberNumber '[-+]\d\+\.\d*' contained display
+
+" Floating point like number with E and no decimal point (+,-)
+syn match amberNumber '[-+]\=\d[[:digit:]]*[eE][\-+]\=\d\+' contained display
+syn match amberNumber '\d[[:digit:]]*[eE][\-+]\=\d\+' contained display
+
+" Floating point like number with E and decimal point (+,-)
+syn match amberNumber '[-+]\=\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' contained display
+syn match amberNumber '\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' contained display
+
+syn region amberString start='"' end='"' contained
+syn region amberDesc start='"' end='"'
+
+syn keyword amberTodo contained TODO FIXME
+syn match amberBang "\v#!.*$"
+syn match amberComment "#.*$" contains=amberTodo
+
+syn keyword amberBlockCmd SHADER BUFFER PIPELINE ATTACH END RUN TYPE SIZE FILL
+syn keyword amberBlockCmd DESCRIPTOR_SET BINDING IDX TO EXPECT PASSTHROUGH
+syn keyword amberBlockCmd DATA_TYPE DIMS DATA SERIES_FROM DRAW_ARRAY IN START_IDX
+syn keyword amberBlockCmd COUNT CLEAR CLEAR_COLOR AS POS DRAW_RECT INC_BY
+syn keyword amberBlockCmd FRAMEBUFFER ENTRY_POINT SHADER_OPTIMIZATION
+
+syn keyword amberComparator EQ NE LT LE GT GE EQ_RGB EQ_RGBA
+
+syn keyword amberKeyword compute vertex geometry fragment graphics
+syn keyword amberKeyword tessellation_evaulation tessellation_control
+
+syn keyword amberFormat GLSL HLSL SPIRV-ASM SPIRV-HEX OPENCL-C
+
+syn keyword amberTopology point_list line_list line_list_with_adjacency
+syn keyword amberTopology line_strip line_strip_with_adjacency triangle_list
+syn keyword amberTopology triangle_list_with_adjacench triangle_strip
+syn keyword amberTopology triangle_strip_with_adjacency triangle_fan patch_list
+
+syn keyword amberBufferType uniform storage vertex index sampled storage color
+syn keyword amberBufferType framebuffer depth
+
+let b:current_syntax = "amber"
+hi def link amberTodo Todo
+hi def link amberBang Comment
+hi def link amberComment Comment
+hi def link amberBlockCmd Keyword
+hi def link amberString String
+hi def link amberNumber Number
+hi def link amberDesc PreProc
+hi def link amberKeyword String
+hi def link amberFormat Type
+hi def link amberComparator Keyword
+hi def link amberTopology Type
+hi def link amberBufferType Type
diff --git a/tools/amber.sublime-syntax b/tools/amber.sublime-syntax
new file mode 100644
index 0000000..fff08fc
--- /dev/null
+++ b/tools/amber.sublime-syntax
@@ -0,0 +1,65 @@
+%YAML 1.2
+---
+name: amber
+file_extensions: [amber]
+scope: source.amber
+contexts:
+ main:
+ # Strings begin and end with quotes, and use backslashes as an escape
+ # character
+ - match: '"'
+ scope: punctuation.definition.string.begin.amber
+ push: double_quoted_string
+
+ # Comments begin with a '#' and finish at the end of the line
+ - match: '#'
+ scope: punctuation.definition.comment.amber
+ push: line_comment
+
+ # Keywords
+ - match: '\b(END|SHADER|BUFFER|DATA_TYPE|SIZE|DIMS|DATA|FILL|SERIES_FROM)\b'
+ scope: keyword.control.amber
+ - match: '\b(PASSTHROUGH|PIPELINE|ATTACH|ENTRY_POINT|DESCRIPTOR_SET|INC_BY)\b'
+ scope: keyword.control.amber
+ - match: '\b(BINDING|IDX|TO|RUN|DRAW_RECT|POS|DRAW_ARRAY|IN|AS|START_IDX)\b'
+ scope: keyword.control.amber
+ - match: '\b(COUNT|CLEAR_COLOR|CLEAR|EXPECT|TYPE|FRAMEBUFFER|SHADER_OPTIMIZATION)\b'
+ scope: keyword.control.amber
+
+ - match: '\b(vertex|fragment|compute|geometry|tessellation_evaluation|tessellation_control)\b'
+ scope: constant.character.escape.amber
+ - match: '\b(framebuffer|graphics)\b'
+ scope: constant.character.escape.amber
+ - match: '\b(uniform|storage|index|sampled|storage|color|depth)\b'
+ scope: constant.character.escape.amber
+ - match: '\b(EQ|NE|LT|LE|GT|GE|EQ_RGB|EQ_RGBA)\b'
+ scope: constant.character.esape.amber
+ - match: '\b(GLSL|HLSL|SPIRV-ASM|SPIRV-HEX|OPENCL-C)\b'
+ scope: constant.character.escape.amber
+
+ - match: '\b(point_list|line_list|line_list_with_adjacency|line_strip)\b'
+ scope: entity.name.type.amber
+ - match: '\b(line_strip_with_adjacency|triangle_list|triangle_list_with_adjacency)\b'
+ scope: entity.name.type.amber
+ - match: '\b(triangle_strip|triangle_strip_with_adjacency|triangle_fan|patch_list)\b'
+ scope: entity.name.type.amber
+
+ - match: '\b(u?int\d*|float|double|vec\d*|mat\d*)\b'
+ scope: entity.name.type.amber
+
+ # Numbers
+ - match: '\b(-)?[0-9.]+\b'
+ scope: constant.numeric.amber
+
+ double_quoted_string:
+ - meta_scope: string.quoted.double.amber
+ - match: '\\.'
+ scope: constant.character.escape.amber
+ - match: '"'
+ scope: punctuation.definition.string.end.amber
+ pop: true
+
+ line_comment:
+ - meta_scope: comment.line.amber
+ - match: $
+ pop: true