-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse strings as namespace, column, or alias names
Added functionality to parse strings as namespace names, column names, or alias names. Additionally, escape characters like double quotes are now supported. This enhances the flexibility of dynamic SQL query parsing and manipulation.
- Loading branch information
Showing
22 changed files
with
546 additions
and
166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace Carbunql.LexicalAnalyzer; | ||
|
||
internal static class CharExtenstions | ||
{ | ||
/// <summary> | ||
/// Defines a set of characters considered as symbols that terminate an identifier. | ||
/// </summary> | ||
private static readonly HashSet<char> Symbols = new HashSet<char> | ||
{ | ||
'+', '-', '*', '/', '%', // Arithmetic operators | ||
'(', ')', '[', ']', '{', '}', // Brackets and braces | ||
'~', '@', '#', '$', '^', '&', // Special symbols | ||
'!', '?', ':', ';', ',', '.', '<', '>', '=', '|', '\\', // Other symbols | ||
'`', '"', '\'' // Quotation marks | ||
}; | ||
|
||
private static readonly HashSet<char> WhiteSpaces = new HashSet<char> | ||
{ | ||
' ', '\t', '\r', '\n', | ||
}; | ||
|
||
private static readonly Dictionary<char, char> ValueEscapePairs = new Dictionary<char, char> | ||
{ | ||
{ '"', '"' }, // ダブルクォート | ||
{ '[', ']' }, // 角括弧 | ||
{ '`', '`' } // バッククォート | ||
}; | ||
|
||
public static bool TryGetDbmsValueEscapeChar(this char c, out char closeChar) | ||
{ | ||
return ValueEscapePairs.TryGetValue(c, out closeChar); | ||
} | ||
|
||
public static bool IsWhiteSpace(this char c) | ||
{ | ||
return WhiteSpaces.Contains(c); | ||
} | ||
|
||
public static bool IsSymbols(this char c) | ||
{ | ||
return Symbols.Contains(c); | ||
} | ||
} |
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
Oops, something went wrong.