chore: improve code
This commit is contained in:
parent
59b1d6c116
commit
07dd66ed07
2 changed files with 17 additions and 4 deletions
|
|
@ -21,7 +21,7 @@ module YAMD::Code
|
|||
DEFAULT = {
|
||||
/\b(?:[A-Z][a-zA-Z\-_0-9]*)\b*/ => 'type',
|
||||
/#(\s|$)[^\n]*/ => 'comment',
|
||||
/\b(?:open|final|class|fn|let|var|if|else|while|loop|return|namespace|new)\b/ => 'kw',
|
||||
/\b(?:open|final|class|struct|enum|fn|let|var|if|else|while|loop|return|namespace|new)\b/ => 'kw',
|
||||
/\b(?:def|import|from)\b/ => 'kw',
|
||||
/\b(?:null|undefined|true|false|this|self)\b/i => 'const',
|
||||
/\b(?:__[a-zA-Z0-9_]+__)\b/i => 'const',
|
||||
|
|
@ -30,6 +30,19 @@ module YAMD::Code
|
|||
/"(?:\\.|[^\\"])*"/ => 'str',
|
||||
/'(?:\\.|[^\\'])*'/ => 'str',
|
||||
}
|
||||
|
||||
GD_SCRIPT = {
|
||||
/\b(?:[A-Z_]+[A-Z_0-9]*)\b/ => 'const',
|
||||
/\b(?:[A-Z][a-zA-Z\-_0-9]*)\b*/ => 'type',
|
||||
/#(\s|$)[^\n]*/ => 'comment',
|
||||
/\b(?:class|struct|enum|var|func|const|if|else|while|return)\b/ => 'kw',
|
||||
/\b(?:class_name|extends)\b/ => 'kw',
|
||||
/\b(?:null|true|false|self)\b/i => 'const',
|
||||
/[:,;()\[\]{}<>]/ => 'punct',
|
||||
/0|(0x[0-9a-fA-F]+)|([1-9][0-9]*(\.[0-9]+)?)/ => 'number',
|
||||
/"(?:\\.|[^\\"])*"/ => 'str',
|
||||
/'(?:\\.|[^\\'])*'/ => 'str',
|
||||
}
|
||||
end
|
||||
|
||||
def self.highlight(txt, highlights=Lang::DEFAULT)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue