From b8c853d742c3de2511d437a7d75d1c86f6d22e5b Mon Sep 17 00:00:00 2001 From: Ian Simonson <ian@iansimonson.com> Date: Thu, 20 Jul 2023 17:26:33 -0700 Subject: [PATCH] Fix attributes and <, > in Odin Lexer (#803) --- lexers/embedded/odin.xml | 4 ++-- lexers/testdata/odin.actual | 2 +- lexers/testdata/odin.expected | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lexers/embedded/odin.xml b/lexers/embedded/odin.xml index 5fca0a3..b984263 100644 --- a/lexers/embedded/odin.xml +++ b/lexers/embedded/odin.xml @@ -51,7 +51,7 @@ <rule pattern = "\#[a-zA-Z_]+\b"> <token type = "NameDecorator"/> </rule> - <rule pattern = "\@\(?[a-zA-Z_]+\b\s*(=\s*"?[0-9a-zA-Z_.]+"?)?\)?"> + <rule pattern = "\@(\([a-zA-Z_]+\b\s*.*\)|\(?[a-zA-Z_]+\)?)"> <token type = "NameAttribute"/> </rule> <rule pattern="[a-zA-Z_]\w*"> @@ -102,7 +102,7 @@ <rule pattern = ""(\\\\|\\"|[^"])*"" > <token type = "LiteralString"/> </rule> - <rule pattern = "(<<=|>>=|<<|>>|<=|>=|&=|&|\+=|-=|\*=|/=|%=|\||\^|=|&&|\|\||--|->|=|==|!=|:=|:|::|\.\.\<|\.\.=|[+\-*/%&])" > + <rule pattern = "(<<=|>>=|<<|>>|<=|>=|&=|&|\+=|-=|\*=|/=|%=|\||\^|=|&&|\|\||--|->|=|==|!=|:=|:|::|\.\.\<|\.\.=|[<>+\-*/%&])" > <token type = "Operator"/> </rule> <rule pattern="[{}()\[\],.;]"> diff --git a/lexers/testdata/odin.actual b/lexers/testdata/odin.actual index ae7801c..1e19373 100644 --- a/lexers/testdata/odin.actual +++ b/lexers/testdata/odin.actual @@ -73,7 +73,7 @@ a_test_proc :: proc(t: ^testing.T) { testing.errnof("a format: %s", value) } -@(disable = ODIN_DEBUG) +@(disable = LOG_LEVEL >= .Debug) debug_thing :: proc(x, y, z: int) { fmt.println(x, y, z) } diff --git a/lexers/testdata/odin.expected b/lexers/testdata/odin.expected index 272c1c2..f0469e8 100644 --- a/lexers/testdata/odin.expected +++ b/lexers/testdata/odin.expected @@ -390,7 +390,7 @@ {"type":"TextWhitespace","value":"\n"}, {"type":"Punctuation","value":"}"}, {"type":"TextWhitespace","value":"\n\n"}, - {"type":"NameAttribute","value":"@(disable = ODIN_DEBUG)"}, + {"type":"NameAttribute","value":"@(disable = LOG_LEVEL \u003e= .Debug)"}, {"type":"TextWhitespace","value":"\n"}, {"type":"Name","value":"debug_thing"}, {"type":"TextWhitespace","value":" "}, @@ -427,7 +427,8 @@ {"type":"TextWhitespace","value":"\n"}, {"type":"Punctuation","value":"}"}, {"type":"TextWhitespace","value":"\n\n"}, - {"type":"NameAttribute","value":"@private\n"}, + {"type":"NameAttribute","value":"@private"}, + {"type":"TextWhitespace","value":"\n"}, {"type":"Name","value":"program"}, {"type":"TextWhitespace","value":" "}, {"type":"Operator","value":":="},