Skip to content

Commit

Permalink
Reimplement the searching for procedure names
Browse files Browse the repository at this point in the history
  • Loading branch information
edukisto committed Dec 20, 2021
1 parent 7a292f2 commit cd99873
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
25 changes: 21 additions & 4 deletions components/prism-odin.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,32 @@
alias: 'keyword'
},

'boolean': /\b(?:false|nil|true)\b/,
/**
* proc is defined below.
*/
'keyword': /\b(?:asm|auto_cast|bit_set|break|case|cast|context|continue|defer|distinct|do|dynamic|else|enum|fallthrough|for|foreign|if|import|in|map|matrix|not_in|or_else|or_return|package|return|struct|switch|transmute|typeid|union|using|when|where)\b/,

'keyword': /\b(?:asm|auto_cast|bit_set|break|case|cast|context|continue|defer|distinct|do|dynamic|else|enum|fallthrough|for|foreign|if|import|in|map|matrix|not_in|or_else|or_return|package|proc|return|struct|switch|transmute|typeid|union|using|when|where)\b/,
/**
* false, nil, true can be used as procedure names. "_" and keywords can't.
*/
'procedure-name': [
{
pattern: /\b\w+(?=[ \t]*(?::[ \n\r\t]*){2}proc\b)/,
alias: 'function'
},
{
pattern: /\b\w+(?=[ \t]*\()/,
alias: 'function'
}
],

'procedure': {
pattern: /\b\w+(?=[ \t]*\()/,
alias: 'function'
pattern: /\bproc\b/,
alias: 'keyword'
},

'boolean': /\b(?:false|nil|true)\b/,

'constant-parameter-sign': {
pattern: /\$/,
alias: 'important'
Expand Down
2 changes: 1 addition & 1 deletion components/prism-odin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/languages/odin/keyword_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ where
["keyword", "or_else"],
["keyword", "or_return"],
["keyword", "package"],
["keyword", "proc"],
["procedure", "proc"],
["keyword", "return"],
["keyword", "struct"],
["keyword", "switch"],
Expand Down
11 changes: 11 additions & 0 deletions tests/languages/odin/procedure_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
do_math()
fibonacci()
log10()

----------------------------------------------------

[
["procedure-name", "do_math"], ["punctuation", "("], ["punctuation", ")"],
["procedure-name", "fibonacci"], ["punctuation", "("], ["punctuation", ")"],
["procedure-name", "log10"], ["punctuation", "("], ["punctuation", ")"]
]
11 changes: 0 additions & 11 deletions tests/languages/odin/procedure_function.test

This file was deleted.

0 comments on commit cd99873

Please sign in to comment.