Skip to content

Commit cd99873

Browse files
committed
Reimplement the searching for procedure names
1 parent 7a292f2 commit cd99873

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

components/prism-odin.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,32 @@
6464
alias: 'keyword'
6565
},
6666

67-
'boolean': /\b(?:false|nil|true)\b/,
67+
/**
68+
* proc is defined below.
69+
*/
70+
'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/,
6871

69-
'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/,
72+
/**
73+
* false, nil, true can be used as procedure names. "_" and keywords can't.
74+
*/
75+
'procedure-name': [
76+
{
77+
pattern: /\b\w+(?=[ \t]*(?::[ \n\r\t]*){2}proc\b)/,
78+
alias: 'function'
79+
},
80+
{
81+
pattern: /\b\w+(?=[ \t]*\()/,
82+
alias: 'function'
83+
}
84+
],
7085

7186
'procedure': {
72-
pattern: /\b\w+(?=[ \t]*\()/,
73-
alias: 'function'
87+
pattern: /\bproc\b/,
88+
alias: 'keyword'
7489
},
7590

91+
'boolean': /\b(?:false|nil|true)\b/,
92+
7693
'constant-parameter-sign': {
7794
pattern: /\$/,
7895
alias: 'important'

components/prism-odin.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/odin/keyword_feature.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ where
6464
["keyword", "or_else"],
6565
["keyword", "or_return"],
6666
["keyword", "package"],
67-
["keyword", "proc"],
67+
["procedure", "proc"],
6868
["keyword", "return"],
6969
["keyword", "struct"],
7070
["keyword", "switch"],
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
do_math()
2+
fibonacci()
3+
log10()
4+
5+
----------------------------------------------------
6+
7+
[
8+
["procedure-name", "do_math"], ["punctuation", "("], ["punctuation", ")"],
9+
["procedure-name", "fibonacci"], ["punctuation", "("], ["punctuation", ")"],
10+
["procedure-name", "log10"], ["punctuation", "("], ["punctuation", ")"]
11+
]

tests/languages/odin/procedure_function.test

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)