Skip to content
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

Limited regular expressions #2504

Open
wants to merge 81 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
19afa9d
updates
gregli-msft Jun 25, 2024
0016eb8
Updates
gregli-msft Jul 1, 2024
601de22
Updates
gregli-msft Jul 2, 2024
c36e21f
Updates
gregli-msft Jul 3, 2024
6347e59
Updates
gregli-msft Jul 3, 2024
a2ab49f
Update Microsoft.PowerFx.Core.Tests.Shared.projitems
gregli-msft Jul 3, 2024
20d2fd3
Update Microsoft.PowerFx.Core.Tests.Shared.projitems
gregli-msft Jul 3, 2024
765b291
Updates
gregli-msft Jul 3, 2024
b514426
Merge branch 'gregli/regex-min' of https://github.com/microsoft/power…
gregli-msft Jul 3, 2024
9b33931
Updates
gregli-msft Jul 3, 2024
b17c233
Merge branch 'main' into gregli/regex-min
gregli-msft Jul 3, 2024
d5463c8
Updates
gregli-msft Jul 3, 2024
2316665
Updates
gregli-msft Jul 3, 2024
ba1e124
Merge branch 'main' into gregli/regex-min
gregli-msft Jul 4, 2024
e2e58ff
Updates
gregli-msft Jul 4, 2024
6349dd9
Updates
gregli-msft Jul 4, 2024
ed49656
Merge branch 'main' into gregli/regex-min
gregli-msft Jul 5, 2024
5105468
Updates
gregli-msft Jul 10, 2024
bbe578d
Updates
gregli-msft Jul 10, 2024
939bf18
Merge branch 'main' into gregli/regex-min
gregli-msft Jul 10, 2024
1c72620
update
gregli-msft Jul 10, 2024
a88f286
Merge branch 'gregli/regex-min' of https://github.com/microsoft/Power…
gregli-msft Jul 10, 2024
428164d
Updates
gregli-msft Jul 10, 2024
d724b82
Merge branch 'main' into gregli/regex-min
gregli-msft Jul 10, 2024
3693147
Updates
gregli-msft Jul 10, 2024
d628f1a
Merge branch 'gregli/regex-min' of https://github.com/microsoft/Power…
gregli-msft Jul 10, 2024
db1405d
Merge branch 'main' into gregli/regex-min
gregli-msft Jul 30, 2024
b79704d
Updates
gregli-msft Aug 3, 2024
15541fc
Updates
gregli-msft Aug 12, 2024
0d0c88c
Updates
gregli-msft Aug 13, 2024
e18f2fe
Updates
gregli-msft Aug 13, 2024
a06654e
Updates
gregli-msft Aug 14, 2024
08d89e0
Updates
gregli-msft Aug 14, 2024
442bf73
updates
gregli-msft Aug 15, 2024
dfa1e15
Updates 2
gregli-msft Aug 15, 2024
9d7ba42
Updates 3
gregli-msft Aug 15, 2024
d51e047
Updates
gregli-msft Aug 16, 2024
e309223
Updates
gregli-msft Aug 22, 2024
ef24bec
Merge branch 'main' into gregli/regex-min
gregli-msft Aug 22, 2024
98ad8e4
Updates
gregli-msft Aug 22, 2024
c55a842
Updates
gregli-msft Aug 30, 2024
c5dfdb0
Merge branch 'main' into gregli/regex-min
gregli-msft Aug 30, 2024
e646a6f
Merge branch 'main' into gregli/regex-min
gregli-msft Aug 30, 2024
856bdfe
Updates
gregli-msft Aug 31, 2024
14d7fe5
Updates
gregli-msft Aug 31, 2024
78d1197
updates
gregli-msft Aug 31, 2024
59bed91
Merge branch 'main' into gregli/regex-min
gregli-msft Aug 31, 2024
3c6f50b
Updates
gregli-msft Aug 31, 2024
9a7e568
Updates
gregli-msft Aug 31, 2024
7bf1438
Updates
gregli-msft Aug 31, 2024
54aea5f
Updates
gregli-msft Sep 1, 2024
df24948
Updates
gregli-msft Sep 1, 2024
d506d23
Updates
gregli-msft Sep 3, 2024
47086b6
Updates
gregli-msft Sep 4, 2024
3904484
Updates
gregli-msft Sep 4, 2024
d7542de
Updates
gregli-msft Sep 4, 2024
273e37e
Updates
gregli-msft Sep 4, 2024
e674cf6
Updates
gregli-msft Sep 6, 2024
280beb2
updates
gregli-msft Sep 6, 2024
01d7098
Updates
gregli-msft Sep 8, 2024
3090dfe
Merge branch 'main' into gregli/regex-min
gregli-msft Sep 8, 2024
a6bb1ad
Updates
gregli-msft Sep 9, 2024
65cadd9
Merge branch 'main' into gregli/regex-min
gregli-msft Sep 20, 2024
d8774a1
Updates
gregli-msft Sep 20, 2024
14afc3b
Updates
gregli-msft Sep 20, 2024
fc1796b
Merge branch 'main' into gregli/regex-min
gregli-msft Sep 27, 2024
709dc9b
Merge branch 'main' into gregli/regex-min
gregli-msft Oct 18, 2024
5615760
updates
gregli-msft Oct 22, 2024
6b4499b
Updates
gregli-msft Oct 24, 2024
fa7edbe
updats
gregli-msft Oct 25, 2024
13ea69a
Updates
gregli-msft Oct 25, 2024
4a254e4
Updates
gregli-msft Oct 25, 2024
18dd7ef
Merge branch 'main' into gregli/regex-min
gregli-msft Oct 29, 2024
a7a9e43
Merge branch 'main' into gregli/regex-min
gregli-msft Nov 6, 2024
46f8221
Updates
gregli-msft Nov 6, 2024
c06bb98
Updates
gregli-msft Nov 7, 2024
4162e1f
update
gregli-msft Nov 7, 2024
03f5190
Updates
gregli-msft Nov 10, 2024
eae88e8
Updates
gregli-msft Nov 13, 2024
f9f9faa
Update
gregli-msft Nov 14, 2024
147ddc5
Update
gregli-msft Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/libraries/Microsoft.PowerFx.Core/Binding/BinderUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.PowerFx.Core.App.Controls;
Expand All @@ -14,6 +15,7 @@
using Microsoft.PowerFx.Core.Localization;
using Microsoft.PowerFx.Core.Logging.Trackers;
using Microsoft.PowerFx.Core.Texl;
using Microsoft.PowerFx.Core.Texl.Builtins;
using Microsoft.PowerFx.Core.Types;
using Microsoft.PowerFx.Core.Types.Enums;
using Microsoft.PowerFx.Core.Utils;
Expand Down Expand Up @@ -1540,6 +1542,49 @@ public static bool TryGetConstantValue(CheckTypesContext context, TexlNode node,
nodeValue = string.Join(string.Empty, parameters);
return true;
}
}
else if (callNode.Head.Name.Value == BuiltinFunctionsCore.Char.Name && callNode.Args.Children.Count == 1)
{
int val = -1;

if (callNode.Args.Children[0].Kind == NodeKind.DecLit)
{
val = (int)((DecLitNode)callNode.Args.Children[0]).ActualDecValue;
}
else if (callNode.Args.Children[0].Kind == NodeKind.NumLit)
{
val = (int)((NumLitNode)callNode.Args.Children[0]).ActualNumValue;
}

if (val < 1 || val > 255)
{
return false;
}

nodeValue = ((char)val).ToString();
return true;
}
else if (callNode.Head.Name.Value == BuiltinFunctionsCore.UniChar.Name && callNode.Args.Children.Count == 1)
{
int val = -1;

if (callNode.Args.Children[0].Kind == NodeKind.DecLit)
{
val = (int)((DecLitNode)callNode.Args.Children[0]).ActualDecValue;
}
else if (callNode.Args.Children[0].Kind == NodeKind.NumLit)
{
val = (int)((NumLitNode)callNode.Args.Children[0]).ActualNumValue;
}

// partial surrogate pair not supported, consistent with interpreter UniChar implementation
if (val < 1 || val > 0x10FFFF || (val >= 0xD800 && val <= 0xDFFF))
{
return false;
}

nodeValue = char.ConvertFromUtf32(val);
return true;
}

break;
Expand Down
40 changes: 40 additions & 0 deletions src/libraries/Microsoft.PowerFx.Core/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,47 @@ internal static class TexlStrings
public static ErrorResourceKey ErrDecimalRequiresPowerFxV1 = new ErrorResourceKey("ErrDecimalNeedsPowerFxV1");

public static ErrorResourceKey ErrInvalidRegEx = new ErrorResourceKey("ErrInvalidRegEx");
public static ErrorResourceKey ErrInvalidRegExBadInlineOptions = new ErrorResourceKey("ErrInvalidRegExBadInlineOptions");
public static ErrorResourceKey ErrInvalidRegExInlineOptionNotAtStart = new ErrorResourceKey("ErrInvalidRegExInlineOptionNotAtStart");
public static ErrorResourceKey ErrInvalidRegExBadOctal = new ErrorResourceKey("ErrInvalidRegExBadOctal");
public static ErrorResourceKey ErrInvalidRegExBadCurly = new ErrorResourceKey("ErrInvalidRegExBadCurly");
public static ErrorResourceKey ErrInvalidRegExBadSquare = new ErrorResourceKey("ErrInvalidRegExBadSquare");
public static ErrorResourceKey ErrInvalidRegExBadParen = new ErrorResourceKey("ErrInvalidRegExBadParen");
public static ErrorResourceKey ErrInvalidRegExBadEscapeInsideCharacterClass = new ErrorResourceKey("ErrInvalidRegExBadEscapeInsideCharacterClass");
public static ErrorResourceKey ErrInvalidRegExBadEscapeInsideNegativeCharacterClass = new ErrorResourceKey("ErrInvalidRegExBadEscapeInsideNegativeCharacterClass");
public static ErrorResourceKey ErrInvalidRegExBadEscapeOutsideCharacterClass = new ErrorResourceKey("ErrInvalidRegExBadEscapeOutsideCharacterClass");
public static ErrorResourceKey ErrInvalidRegExRepeatInCharClass = new ErrorResourceKey("ErrInvalidRegExRepeatInCharClass");
public static ErrorResourceKey ErrInvalidRegExRepeatedInlineOption = new ErrorResourceKey("ErrInvalidRegExRepeatedInlineOption");
public static ErrorResourceKey ErrInvalidRegExInlineOptionConflictsWithNumberedSubMatches = new ErrorResourceKey("ErrInvalidRegExInlineOptionConflictsWithNumberedSubMatches");
public static ErrorResourceKey ErrInvalidRegExConflictingInlineOptions = new ErrorResourceKey("ErrInvalidRegExConflictingInlineOptions");
public static ErrorResourceKey ErrInvalidRegExBadQuantifier = new ErrorResourceKey("ErrInvalidRegExBadQuantifier");
public static ErrorResourceKey ErrInvalidRegExBadBackRefSelfReferencing = new ErrorResourceKey("ErrInvalidRegExBadBackRefSelfReferencing");
public static ErrorResourceKey ErrInvalidRegExBadBackRefNotDefined = new ErrorResourceKey("ErrInvalidRegExBadBackRefNotDefined");
public static ErrorResourceKey ErrInvalidRegExBadBackRefNumber = new ErrorResourceKey("ErrInvalidRegExBadBackRefNumber");
public static ErrorResourceKey ErrInvalidRegExBadBalancing = new ErrorResourceKey("ErrInvalidRegExBadBalancing");
public static ErrorResourceKey ErrInvalidRegExBadSingleQuoteNamedCapture = new ErrorResourceKey("ErrInvalidRegExBadSingleQuoteNamedCapture");
public static ErrorResourceKey ErrInvalidRegExBadEscape = new ErrorResourceKey("ErrInvalidRegExBadEscape");
public static ErrorResourceKey ErrInvalidRegExBadConditional = new ErrorResourceKey("ErrInvalidRegExBadConditional");
public static ErrorResourceKey ErrInvalidRegExBadNamedCaptureAlreadyExists = new ErrorResourceKey("ErrInvalidRegExBadNamedCaptureAlreadyExists");
public static ErrorResourceKey ErrInvalidRegExBadNamedCaptureName = new ErrorResourceKey("ErrInvalidRegExBadNamedCaptureName");
public static ErrorResourceKey ErrInvalidRegExBadCharacterClassLiteralSquareBracket = new ErrorResourceKey("ErrInvalidRegExBadCharacterClassLiteralSquareBracket");
public static ErrorResourceKey ErrInvalidRegExUnclosedCaptureGroups = new ErrorResourceKey("ErrInvalidRegExUnclosedCaptureGroups");
public static ErrorResourceKey ErrInvalidRegExUnclosedInlineComment = new ErrorResourceKey("ErrInvalidRegExUnclosedInlineComment");
public static ErrorResourceKey ErrInvalidRegExUnopenedCaptureGroups = new ErrorResourceKey("ErrInvalidRegExUnopenedCaptureGroups");
public static ErrorResourceKey ErrInvalidRegExUnclosedCharacterClass = new ErrorResourceKey("ErrInvalidRegExUnclosedCharacterClass");
public static ErrorResourceKey ErrInvalidRegExMixingNamedAndNumberedSubMatches = new ErrorResourceKey("ErrInvalidRegExMixingNamedAndNumberedSubMatches");
public static ErrorResourceKey ErrInvalidRegExNumberedSubMatchesDisabled = new ErrorResourceKey("ErrInvalidRegExNumberedSubMatchesDisabled");
public static ErrorResourceKey ErrInvalidRegExBadUnsupportedCharacterClassSubtraction = new ErrorResourceKey("ErrInvalidRegExBadUnsupportedCharacterClassSubtraction");
public static ErrorResourceKey ErrInvalidRegExOpenParenInComment = new ErrorResourceKey("ErrInvalidRegExOpenParenInComment");
public static ErrorResourceKey ErrInvalidRegExLiteralHyphenInCharacterClass = new ErrorResourceKey("ErrInvalidRegExLiteralHyphenInCharacterClass");
public static ErrorResourceKey ErrInvalidRegExBackRefInCharacterClass = new ErrorResourceKey("ErrInvalidRegExBackRefInCharacterClass");
public static ErrorResourceKey ErrInvalidRegExUnescapedCharInCharacterClass = new ErrorResourceKey("ErrInvalidRegExUnescapedCharInCharacterClass");
public static ErrorResourceKey ErrInvalidRegExUnescapedParensInCharacterClass = new ErrorResourceKey("ErrInvalidRegExUnescapedParensInCharacterClass");
public static ErrorResourceKey ErrInvalidRegExBadUnicodeCategory = new ErrorResourceKey("ErrInvalidRegExBadUnicodeCategory");
public static ErrorResourceKey ErrInvalidRegExEmptyCharacterClass = new ErrorResourceKey("ErrInvalidRegExEmptyCharacterClass");

public static ErrorResourceKey ErrVariableRegEx = new ErrorResourceKey("ErrVariableRegEx");
public static ErrorResourceKey ErrVariableRegExOptions = new ErrorResourceKey("ErrVariableRegExOptions");
public static ErrorResourceKey InfoRegExCaptureNameHidesPredefinedFullMatchField = new ErrorResourceKey("InfoRegExCaptureNameHidesPredefinedFullMatchField");
public static ErrorResourceKey InfoRegExCaptureNameHidesPredefinedSubMatchesField = new ErrorResourceKey("InfoRegExCaptureNameHidesPredefinedSubMatchesField");
public static ErrorResourceKey InfoRegExCaptureNameHidesPredefinedStartMatchField = new ErrorResourceKey("InfoRegExCaptureNameHidesPredefinedStartMatchField");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public override void Visit(IValueVisitor visitor)
visitor.Visit(this);
}

internal StringValue ToLower()
{
return new StringValue(IRContext.NotInSource(FormulaType.String), Value.ToLowerInvariant());
}

public override void ToExpression(StringBuilder sb, FormulaValueSerializerSettings settings)
{
sb.Append($"\"{CharacterUtils.ExcelEscapeString(Value)}\"");
Expand Down
61 changes: 0 additions & 61 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/IsMatch.cs

This file was deleted.

Loading
Loading