-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error handling in the DFA builder et al. (#350)
* Skip building the DFA if parsing a string regex fails. * Simplify tracking state when visiting regexes. We don't need to separately track is/has void; we can only track the latter. And failed string regexes are specially tracked and do not emit `FARKLE0003`. * Avoid stack overflows when processing too deeply nested regexes. * Improve documentation. Add example for `FARKLE0001` and consistently use "regex" instead of "regular expression".
- Loading branch information
1 parent
29c378e
commit 0653016
Showing
10 changed files
with
134 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 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 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 @@ | ||
--- | ||
category: Diagnostic codes | ||
categoryindex: 3 | ||
title: FARKLE0010 | ||
description: FARKLE0010: Regex is too complex | ||
--- | ||
# FARKLE0010: Regex is too complex | ||
|
||
This error is emitted when Farkle fails to process a regex because it reached a limitation of the library or the system. In this case no DFA gets built and the grammar cannot be used for tokenizing. | ||
|
||
The precise circumstances that trigger this error are an implementation detail, but encountering it is not expected to be common when working with real-world regexes. |
This file contains 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 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,26 @@ | ||
// Copyright © Theodore Tsirpanis and Contributors. | ||
// SPDX-License-Identifier: MIT | ||
|
||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER | ||
global using RuntimeHelpersCompat = System.Runtime.CompilerServices.RuntimeHelpers; | ||
#else | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Farkle.Compatibility; | ||
|
||
internal static class RuntimeHelpersCompat | ||
{ | ||
public static bool TryEnsureSufficientExecutionStack() | ||
{ | ||
try | ||
{ | ||
RuntimeHelpers.EnsureSufficientExecutionStack(); | ||
} | ||
catch (InsufficientExecutionStackException) | ||
{ | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
#endif |
This file contains 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 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 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 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 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