-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Added support for Odin #3280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Added support for Odin #3280
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
71378a0
Add Odin
edukisto f46e69d
Change \S\s to \s\S
edukisto 3a67123
Add support for comments with 1 level of nesting
edukisto 68fca76
Fix tests for comments
edukisto d87b7fe
Fix the comment pattern to prevent exponential backtracking
edukisto f0e1bd1
Add a missing newline to the JSDoc block
edukisto f0eff95
Make the char pattern greedy
edukisto f7569f0
Allow spaces and tabs after the name of a function
edukisto ee47b20
Separate directives, operators, punctuation marks, etc.
edukisto babdd8c
Fix errors
edukisto 7a292f2
Make _ a discard variable
edukisto cd99873
Reimplement the searching for procedure names
edukisto 95e8b90
Simplified proc matching
RunDevelopment 9ee49f9
Improved number pattern
RunDevelopment 9770e09
Simplified escape handling
RunDevelopment 9f52675
Rebuild
RunDevelopment 6e85ff4
Merge pull request #1 from RunDevelopment/impr-3204
edukisto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| (function (Prism) { | ||
| var escapes = /\\(?:["'\\abefnrtv]|0[0-7]{2}|U[\dA-Fa-f]{6}|u[\dA-Fa-f]{4}|x[\dA-Fa-f]{2})/; | ||
|
|
||
| Prism.languages.odin = { | ||
| /** | ||
| * The current implementation supports only 1 level of nesting. | ||
| * | ||
| * @author Michael Schmidt | ||
| * @author edukisto | ||
| */ | ||
| 'comment': [ | ||
| { | ||
| pattern: /\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:\*(?!\/)|[^*])*(?:\*\/|$))*(?:\*\/|$)/, | ||
| greedy: true | ||
| }, | ||
| { | ||
| pattern: /#![^\n\r]*/, | ||
| greedy: true | ||
| }, | ||
| { | ||
| pattern: /\/\/[^\n\r]*/, | ||
RunDevelopment marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| greedy: true | ||
| } | ||
| ], | ||
|
|
||
| /** | ||
| * Should be found before strings because of '"'"- and '`'`-like sequences. | ||
| */ | ||
| 'char': { | ||
| pattern: /'(?:\\(?:.|[0Uux][0-9A-Fa-f]{1,6})|[^\n\r'\\])'/, | ||
| greedy: true, | ||
| inside: { | ||
| 'symbol': escapes | ||
| } | ||
| }, | ||
|
|
||
| 'string': [ | ||
| { | ||
| pattern: /`[^`]*`/, | ||
| greedy: true | ||
| }, | ||
| { | ||
| pattern: /"(?:\\.|[^\n\r"\\])*"/, | ||
| greedy: true, | ||
| inside: { | ||
| 'symbol': escapes | ||
| } | ||
| } | ||
| ], | ||
|
|
||
| 'directive': { | ||
| pattern: /#\w+/, | ||
| alias: 'property' | ||
| }, | ||
|
|
||
| 'number': /\b0(?:b[01_]+|d[\d_]+|h_*(?:(?:(?:[\dA-Fa-f]_*){8}){1,2}|(?:[\dA-Fa-f]_*){4})|o[0-7_]+|x[\dA-F_a-f]+|z[\dAB_ab]+)\b|(?:\b\d+(?:\.(?!\.)\d*)?|\B\.\d+)(?:[Ee][+-]?\d*)?[ijk]?(?!\w)/, | ||
|
|
||
| 'discard': { | ||
| pattern: /\b_\b/, | ||
| alias: 'keyword' | ||
| }, | ||
|
|
||
| 'procedure-definition': { | ||
| pattern: /\b\w+(?=[ \t]*(?::\s*){2}proc\b)/, | ||
| alias: 'function' | ||
| }, | ||
|
|
||
| '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]*\()/, | ||
| alias: 'function' | ||
| }, | ||
|
|
||
| 'boolean': /\b(?:false|nil|true)\b/, | ||
|
|
||
| 'constant-parameter-sign': { | ||
| pattern: /\$/, | ||
| alias: 'important' | ||
| }, | ||
|
|
||
| 'undefined': { | ||
| pattern: /---/, | ||
| alias: 'operator' | ||
| }, | ||
|
|
||
| 'arrow': { | ||
| pattern: /->/, | ||
| alias: 'punctuation' | ||
| }, | ||
|
|
||
| 'operator': /\+\+|--|\.\.[<=]?|(?:&~|[-!*+/=~]|[%&<>|]{1,2})=?|[?^]/, | ||
|
|
||
| 'punctuation': /[(),.:;@\[\]{}]/ | ||
RunDevelopment marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
| }(Prism)); | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <h2>Example</h2> | ||
|
|
||
| <pre><code>package main | ||
|
|
||
| import "core:fmt" | ||
|
|
||
| main :: proc() { | ||
| i: int | ||
| for i := 0; i < 100; i += 1 { | ||
| fmt.println(i, " bottles of beer on the wall.\n") | ||
| } | ||
| }</code></pre> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| false | ||
| nil | ||
| true | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["boolean", "false"], | ||
| ["boolean", "nil"], | ||
| ["boolean", "true"] | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| ' ' | ||
| '!' | ||
| '"' | ||
| '0' | ||
| '\"' | ||
| '\'' | ||
| '\000' | ||
| '\077' | ||
| '\U000000' | ||
| '\UFFFFFF' | ||
| '\Uffffff' | ||
| '\\' | ||
| '\a' | ||
| '\b' | ||
| '\e' | ||
| '\f' | ||
| '\n' | ||
| '\r' | ||
| '\t' | ||
| '\u0000' | ||
| '\uFFFF' | ||
| '\uffff' | ||
| '\v' | ||
| '\x00' | ||
| '\xFF' | ||
| '\xff' | ||
| 'a' | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["char", ["' '"]], | ||
| ["char", ["'!'"]], | ||
| ["char", ["'\"'"]], | ||
| ["char", ["'0'"]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\\""], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\'"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\000"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\077"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\U000000"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\UFFFFFF"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\Uffffff"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\\\"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\a"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\b"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\e"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\f"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\n"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\r"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\t"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\u0000"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\uFFFF"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\uffff"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\v"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\x00"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\xFF"], | ||
| "'" | ||
| ]], | ||
| ["char", [ | ||
| "'", | ||
| ["symbol", "\\xff"], | ||
| "'" | ||
| ]], | ||
| ["char", ["'a'"]] | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| #! | ||
| #! A comment | ||
| #!! | ||
| #!"" | ||
| #!#! | ||
| #!' ' | ||
| #!/**/ | ||
| #!// | ||
| #!0 | ||
| #!`` | ||
| #!false | ||
| #!if | ||
| /* | ||
| */ | ||
| /* 1 /* 2 */ 1 */ | ||
| /* A comment */ | ||
| /*!*/ | ||
| /*""*/ | ||
| /*"\a"*/ | ||
| /*#!*/ | ||
| /*' '*/ | ||
| /*'\a'*/ | ||
| /**/ | ||
| /*/**/*/ | ||
| /*0*/ | ||
| /*`\a`*/ | ||
| /*``*/ | ||
| /*false*/ | ||
| /*if*/ | ||
| // | ||
| // A comment | ||
| //! | ||
| //"" | ||
| //#! | ||
| //' ' | ||
| ///**/ | ||
| //// | ||
| //0 | ||
| //`` | ||
| //false | ||
| //if | ||
| Not a comment #! A comment | ||
| Not a comment /* A comment */ | ||
| Not a comment // A comment | ||
RunDevelopment marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["comment", "#!"], | ||
| ["comment", "#! A comment"], | ||
| ["comment", "#!!"], | ||
| ["comment", "#!\"\""], | ||
| ["comment", "#!#!"], | ||
| ["comment", "#!' '"], | ||
| ["comment", "#!/**/"], | ||
| ["comment", "#!//"], | ||
| ["comment", "#!0"], | ||
| ["comment", "#!``"], | ||
| ["comment", "#!false"], | ||
| ["comment", "#!if"], | ||
| ["comment", "/*\r\n*/"], | ||
| ["comment", "/* 1 /* 2 */ 1 */"], | ||
| ["comment", "/* A comment */"], | ||
| ["comment", "/*!*/"], | ||
| ["comment", "/*\"\"*/"], | ||
| ["comment", "/*\"\\a\"*/"], | ||
| ["comment", "/*#!*/"], | ||
| ["comment", "/*' '*/"], | ||
| ["comment", "/*'\\a'*/"], | ||
| ["comment", "/**/"], | ||
| ["comment", "/*/**/*/"], | ||
| ["comment", "/*0*/"], | ||
| ["comment", "/*`\\a`*/"], | ||
| ["comment", "/*``*/"], | ||
| ["comment", "/*false*/"], | ||
| ["comment", "/*if*/"], | ||
| ["comment", "//"], | ||
| ["comment", "// A comment"], | ||
| ["comment", "//!"], | ||
| ["comment", "//\"\""], | ||
| ["comment", "//#!"], | ||
| ["comment", "//' '"], | ||
| ["comment", "///**/"], | ||
| ["comment", "////"], | ||
| ["comment", "//0"], | ||
| ["comment", "//``"], | ||
| ["comment", "//false"], | ||
| ["comment", "//if"], | ||
| "\r\nNot a comment ", ["comment", "#! A comment"], | ||
| "\r\nNot a comment ", ["comment", "/* A comment */"], | ||
| "\r\nNot a comment ", ["comment", "// A comment"] | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| $ | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["constant-parameter-sign", "$"] | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #assert | ||
| #no_bounds_check | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["directive", "#assert"], | ||
| ["directive", "#no_bounds_check"] | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.