Skip to content

Commit 1286375

Browse files
authored
Merge pull request #558 from frg2089/dev
Add annotations for regular expressions in LexemeAttribute
2 parents 4c3754c + 5f2fe6e commit 1286375

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/sly/lexer/attributes/LexemeAttribute.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics.CodeAnalysis;
23

34
namespace sly.lexer
45
{
@@ -14,7 +15,7 @@ public class LexemeAttribute : Attribute
1415

1516
internal string Mode { get; set; }
1617

17-
public LexemeAttribute(string pattern, bool isSkippable = false, bool isLineEnding = false)
18+
public LexemeAttribute([StringSyntax(StringSyntaxAttribute.Regex)] string pattern, bool isSkippable = false, bool isLineEnding = false)
1819
{
1920
Pattern = pattern;
2021
IsSkippable = isSkippable;
@@ -55,6 +56,7 @@ public LexemeAttribute(GenericToken generic, IdentifierType idType, string start
5556

5657
public string IdentifierRestPattern { get; }
5758

59+
[StringSyntax(StringSyntaxAttribute.Regex)]
5860
public string Pattern { get; set; }
5961

6062
public bool IsSkippable { get; set; }

src/sly/sly.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
<PrivateAssets>all</PrivateAssets>
3838
</PackageReference>
3939
<PackageReference Include="Newtonsoft.Json" Version="13.0.2"/>
40+
<PackageReference Include="PolySharp" Version="1.15.0" Condition=" $(TargetFramework.StartsWith('netstandard')) OR '$(TargetFramework)' == 'net6.0'">
41+
<PrivateAssets>all</PrivateAssets>
42+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
43+
</PackageReference>
4044
<PackageReference Include="System.Collections.Immutable" Version="6.0.0"/>
4145
<PackageReference Include="System.ValueTuple" Version="4.6.0"/>
4246
</ItemGroup>

0 commit comments

Comments
 (0)