Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/56345 )

Change subject: util: Add a ucode syntax highlighting file for vim.
......................................................................

util: Add a ucode syntax highlighting file for vim.

Change-Id: Id7720b31b59a5490abb45f49beaf461e2e46cb71
---
A util/vi/ucode.vim
1 file changed, 150 insertions(+), 0 deletions(-)



diff --git a/util/vi/ucode.vim b/util/vi/ucode.vim
new file mode 100644
index 0000000..094758d
--- /dev/null
+++ b/util/vi/ucode.vim
@@ -0,0 +1,141 @@
+" Copyright 2022 Google, Inc.
+"
+" Redistribution and use in source and binary forms, with or without
+" modification, are permitted provided that the following conditions are
+" met: redistributions of source code must retain the above copyright
+" notice, this list of conditions and the following disclaimer;
+" redistributions in binary form must reproduce the above copyright
+" notice, this list of conditions and the following disclaimer in the
+" documentation and/or other materials provided with the distribution;
+" neither the name of the copyright holders nor the names of its
+" contributors may be used to endorse or promote products derived from
+" this software without specific prior written permission.
+"
+" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+" To install, copy this file to ~/.vim/syntax/ucode.vim. To use it manually,
+" run this command.
+"
+" set syntax=ucode
+"
+" To make vim use it automatically when opening new ucode files, add this line
+" to your vimrc.
+"
+" autocmd BufNewFile,BufRead *.ucode set syntax=ucode
+
+
+" Clear out any existing syntax highlighting.
+:if exists("b:current_syntax")
+:    unlet b:current_syntax
+:endif
+
+" Include python syntax highlighting for macro arguments and bodies.
+:syntax include @python syntax/python.vim
+
+" Highlighting for comments
+:syntax match Comment '#.*'
+:syntax region multilineComment start='\/\*' end='\*\/'
+:highlight link multilineComment Comment
+
+" Some top level keywords.
+:syntax keyword Keyword def nextgroup=macroopGroup,romGroup,macroGroup
+    \ skipwhite
+:syntax keyword Keyword undef nextgroup=macroGroup skipwhite
+
+" Objects that can be defined
+:syntax keyword macroopKeyword macroop nextgroup=id skipwhite
+:highlight link macroopKeyword Structure
+:syntax keyword romKeyword rom
+:highlight link romKeyword Structure
+
+" Ojbects that can be undefined (and also defined)
+:syntax keyword macroKeyword macro nextgroup=id skipwhite
+:highlight link macroKeyword Macro
+
+" Parameters for a macro.
+:syntax region regionParams
+    \ start='\(def\s\+macro\s\+[A-Za-z_]\w*\)\@<=\(\s\+\)'
+    \ end='\({\)\@=' contains=@python
+
+" Identifiers. These must follow a macro def or undef, or a macroop def.
+:syntax match id
+    \ '\(\(\(def\s\+macro\)\|
+          \\(def\s\+macroop\)\|
+          \\(undef\s\+macro\)\)\s\+\)\@<=
+       \\([A-Za-z_]\w\+\)'
+    \ nextgroup=block,regionParams
+:highlight link id Identifier
+
+" Highlighting for include file name strings
+:syntax region ucodeString start='\(include\s*\)\@<="' skip='\\.' end='"'
+:highlight link ucodeString String
+
+" Blocks. These are everything from a top level { to the next } which is not
+" part of a python string, or in a comment, and is the first non-whitespace
+" character on its line. The {}s are not considered part of the block.
+:syntax match block '\%({\)\@<=
+        \\%(\_[^"\'/#]\|
+        \\%("\%(""\)\@!\%([^"\\]\|\%(\\\_.\)\)*"\)\|
+        \\%(\'\(\'\'\)\@!\%([^\'\\]\|\%(\\\_.\)\)*\'\)\|
+        \\%("""\%(\_[^"\\]\|\%(\\\_.\)\)*"""\)\|
+        \\%(\'\'\'\%(\_[^\'\\]\|\%(\\\_.\)\)*\'\'\'\)\|
+        \\%(/\*\%([^*]\|\%(\\\_.\)\)*\*/\)\|
+        \\%(#.*\)\)\{-}\
+    \(^\s*}\)\@=' fold transparent
+
+" Statements. These are everything on one line, ignoring newlines in strings
+" or comments, or if escaped.
+:syntax match blockStatement '^\%([^"\'/#]\|
+    \\%("\%(""\)\@!\%([^"\\]\|\%(\\\_.\)\)*"\)\|
+    \\%(\'\(\'\'\)\@!\%([^\'\\]\|\%(\\\_.\)\)*\'\)\|
+    \\%("""\%(\_[^"\\]\|\%(\\\_.\)\)*"""\)\|
+    \\%(\'\'\'\%(\_[^\'\\]\|\%(\\\_.\)\)*\'\'\'\)\|
+    \\%(/\*\%([^*]\|\%(\\\_.\)\)*\*/\)\|
+    \\%(#.*\)\|
+    \\%(\\\_.\)\)\{-}$' containedin=block transparent
+
+
+" All these components of a statement eat their leading whitespace and so can +" start a line. They need to be ordered with the first thing last so that the +" first 'match' takes priority. They then feed into each other in order using
+" the 'nextgroup' setting.
+
+" Statement args. Matched in the same way as an entire statement.
+:syntax match statementArgs '\%([^"\'/#]\|
+    \\%("\%(""\)\@!\%([^"\\]\|\%(\\\_.\)\)*"\)\|
+    \\%(\'\(\'\'\)\@!\%([^\'\\]\|\%(\\\_.\)\)*\'\)\|
+    \\%("""\%(\_[^"\\]\|\%(\\\_.\)\)*"""\)\|
+    \\%(\'\'\'\%(\_[^\'\\]\|\%(\\\_.\)\)*\'\'\'\)\|
+    \\%(/\*\%([^*]\|\%(\\\_.\)\)*\*/\)\|
+    \\%(#.*\)\|
+    \\%(\\\_.\)\)\{-}$' containedin=blockStatement contains=@python
+
+" Statement op. Just an identifier, optionally with a '.' in front of it if
+" it's a directive.
+:syntax match statementOp '\s*.\=[A-Za-z_]\w*'
+    \ containedin=blockStatement nextgroup=statementArgs skipwhite
+:highlight link statementOp Function
+
+" The label itself, which must have a ':' after it.
+:syntax match statementLabel '\s*[A-Za-z_]\w*\s*\%(:\)\@='
+    \ containedin=blockStatement nextgroup=statementOp skipwhite
+:highlight link statementLabel Label
+
+" Possible extern keyword.
+:syntax match externLabel '\s*extern'
+    \ containedin=blockStatement nextgroup=statementLabel skipwhite
+:highlight link externLabel StorageClass
+
+:syntax match include '^\s*include' nextgroup=ucodeString skipwhite
+:highlight link include PreProc

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/56345
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Id7720b31b59a5490abb45f49beaf461e2e46cb71
Gerrit-Change-Number: 56345
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to