Skip to content

Commit

Permalink
Update Odin lexer for new build tag feature (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
iansimonson authored Jan 11, 2025
1 parent 0bd7c68 commit f0d460e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lexers/embedded/odin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@
<rule pattern = "\#[a-zA-Z_]+\b">
<token type = "NameDecorator"/>
</rule>
<rule pattern = "^\#\+\w+\s*$">
<token type = "NameAttribute"/>
</rule>
<rule pattern = "^(\#\+\w+)(\s+)(\!)?([A-Za-z0-9-_!]+)(?:(,)(\!)?([A-Za-z0-9-_!]+))*\s*$">
<bygroups>
<token type = "NameAttribute"/>
<token type = "TextWhitespace"/>
<token type = "Operator"/>
<token type = "Name"/>
<token type = "Punctuation"/>
<token type = "Operator"/>
<token type = "Name"/>
</bygroups>
</rule>
<rule pattern = "\@(\([a-zA-Z_]+\b\s*.*\)|\(?[a-zA-Z_]+\)?)">
<token type = "NameAttribute"/>
</rule>
Expand Down
3 changes: 3 additions & 0 deletions lexers/testdata/odin.actual
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#+feature dynamic-literals
#+build windows,!linux
#+ignore
package main

import "core:fmt"
Expand Down
13 changes: 13 additions & 0 deletions lexers/testdata/odin.expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
[
{"type":"NameAttribute","value":"#+feature"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"dynamic-literals"},
{"type":"TextWhitespace","value":"\n"},
{"type":"NameAttribute","value":"#+build"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"windows"},
{"type":"Punctuation","value":","},
{"type":"Operator","value":"!"},
{"type":"Name","value":"linux"},
{"type":"TextWhitespace","value":"\n"},
{"type":"NameAttribute","value":"#+ignore"},
{"type":"TextWhitespace","value":"\n"},
{"type":"KeywordNamespace","value":"package"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"main"},
Expand Down

0 comments on commit f0d460e

Please sign in to comment.