Skip to content

Instantly share code, notes, and snippets.

@AurelienFT
Created June 24, 2019 01:27
Show Gist options
  • Save AurelienFT/49ffe2b04d80e7e8694be1488c4b0aec to your computer and use it in GitHub Desktop.
Save AurelienFT/49ffe2b04d80e7e8694be1488c4b0aec to your computer and use it in GitHub Desktop.
#################################################################
## Iro
################################################################
##
## * Press Ctrl + '+'/'-' To Zoom in
## * Press Ctrl + S to save and recalculate...
## * Documents are saved to web storage.
## * Only one save slot supported.
## * Matches cannot span lines.
## * Unicode chars must be defined in \u0000 to \uffff format.
## * All matches must be contained by a single group ( ... )
## * Look behinds not permitted, (?<= or (?<!
## * Look forwards are permitted (?= or (?!
## * Constants are defined as __my_const = (......)
## * The \= format allows unescaped regular expressions
## * Constants referenced by match \= $${__my_const}
## * Constants can reference other constants
## * You are free to delete all the default scopes.
## * Twitter : ainslec , Web: http://eeyo.io/iro
##
################################################################
name = V
file_extensions [] = v,vh;
################################################################
## Constants
################################################################
__MY_CONSTANT \= (\b[a-z][a-z0-9]*)
################################################################
## Styles
################################################################
styles [] {
.comment : style {
color = light_green
italic = true
ace_scope = comment
textmate_scope = comment
pygments_scope = Comment
}
.keyword : style {
color = blue
ace_scope = keyword
textmate_scope = keyword
pygments_scope = Keyword
}
.type : style {
color = green
ace_scope = keyword
textmate_scope = keyword
pygments_scope = Keyword
}
.numeric : style {
color = gold
ace_scope = constant.numeric
textmate_scope = constant.numeric
pygments_scope = Number
}
.punctuation : style {
color = red_2
ace_scope = punctuation
textmate_scope = punctuation
pygments_scope = Punctuation
}
.text : style {
color = brown
ace_scope = text
textmate_scope = text
pygments_scope = String
}
.code : style {
color = white
ace_scope = text
textmate_scope = text
pygments_scope = String
}
.illegal : style {
color = brown
background_color = red
ace_scope = invalid
textmate_scope = invalid
pygments_scope = Generic.Error
}
}
#################################################
## Parse contexts
#################################################
contexts [] {
##############################################
## Main Context - Entry point context
##############################################
main : context {
: pattern {
regex \= (\\bbreak\b|\bconst\b|\bcontinue\b|\bdefer\b|\belse\b|\benum\b|\bfn\b|\bfor\b|\bgo\b|\bgoto\b|\bif\b|\bimport\b|\bbin\b|\binterface\b|\bmatch\b|\bmodule\b|\bmut\b|\bor\b|\bpub\b|\breturn\b|\bstruct\b|\btype\b)
styles [] = .keyword;
}
: pattern {
regex \= (\\bbool\b|\bstring\b|\bi8\b|\bi16\b|\bi32\b|\bi64\b|\bi128\b)
styles [] = .type;
}
: include "numeric" ;
: inline_push {
regex \= (\{)
styles [] = .punctuation;
: pop {
regex \= (\})
styles [] = .punctuation;
}
: include "main" ;
}
: pattern {
regex \= (;)
styles [] = .punctuation;
}
: inline_push {
regex \= (\')
styles [] = .punctuation;
default_style = .text
: pop {
regex \= (\')
styles [] = .punctuation;
}
}
: inline_push {
regex \= (\()
styles [] = .punctuation;
: pop {
regex \= (\))
styles [] = .punctuation;
}
: include "numeric" ;
: pattern {
regex \= (,)
styles [] = .punctuation;
}
}
: include "multi_line_comment" ;
: pattern {
regex \= (//.*)
styles [] = .comment;
}
: pattern {
regex \= ([^\s])
styles [] = .code;
}
}
#################################################
## End of Contexts
#################################################
###########################################
## Numeric Context
###########################################
numeric : context {
: pattern {
regex \= (\b\d+)
styles [] = .numeric;
}
}
###########################################
## Multi Line Comment Context
###########################################
multi_line_comment : context {
description = multiline
: inline_push {
regex \= (/\*)
styles [] = .comment;
default_style = .comment
: pop {
regex \= (\*/)
styles [] = .comment;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment