-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto upper standard data types (#37)
- Loading branch information
Showing
6 changed files
with
285 additions
and
7 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,185 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace TcBlack | ||
{ | ||
class Keywords | ||
{ | ||
protected static MatchEvaluator KeywordsEval = new MatchEvaluator(UpText); | ||
protected static string[] KeywordList = | ||
{ | ||
"abs", | ||
"acos", | ||
"add", | ||
"adr", | ||
"and", | ||
"andn", | ||
"any_date", | ||
"any_int", | ||
"any_num", | ||
"any_real", | ||
"any_sintrg", | ||
"any", | ||
"array", | ||
"asin", | ||
"at", | ||
"atan", | ||
"bitadr", | ||
"bool", | ||
"by", | ||
"byte", | ||
"cal", | ||
"calc", | ||
"calcn", | ||
"case", | ||
"constant", | ||
"cos", | ||
"date_and_time", | ||
"date", | ||
"dint", | ||
"div", | ||
"do", | ||
"dt", | ||
"dword", | ||
"else", | ||
"elsif", | ||
"end_case", | ||
"end_for", | ||
"end_if", | ||
"end_repeat", | ||
"end_struct", | ||
"end_type", | ||
"end_var", | ||
"end_while", | ||
"eq", | ||
"exit", | ||
"exp", | ||
"expt", | ||
"false", | ||
"for", | ||
"function_block", | ||
"function", | ||
"ge", | ||
"gt", | ||
"if", | ||
"indexof", | ||
"int", | ||
"jmp", | ||
"jmpc", | ||
"jmpcn", | ||
"ld", | ||
"ldn", | ||
"le", | ||
"lint", | ||
"ln", | ||
"log", | ||
"lreal", | ||
"lt", | ||
"ltime", | ||
"lword", | ||
"max", | ||
"method", | ||
"min", | ||
"mod", | ||
"move", | ||
"mul", | ||
"mux", | ||
"ne", | ||
"not", | ||
"of", | ||
"or", | ||
"orn", | ||
"params", | ||
"persistent", | ||
"pointer", | ||
"program", | ||
"r", | ||
"read_only", | ||
"read_write", | ||
"real", | ||
"reference", | ||
"repeat", | ||
"ret", | ||
"retain", | ||
"retc", | ||
"retcn", | ||
"return", | ||
"rol", | ||
"ror", | ||
"s", | ||
"sel", | ||
"shl", | ||
"shr", | ||
"sin", | ||
"sint", | ||
"sizeof", | ||
"sqrt", | ||
"st", | ||
"stn", | ||
"string", | ||
"struct", | ||
"sub", | ||
"super", | ||
"super", | ||
"tan", | ||
"then", | ||
"this", | ||
"time_of_day", | ||
"time", | ||
"to", | ||
"tod", | ||
"true", | ||
"trunc", | ||
"type", | ||
@"t#(?:\d+(?:ms|s|m|h|d))+", | ||
"udint", | ||
"uint", | ||
"ulint", | ||
"until", | ||
"usint", | ||
"uxint", | ||
"var_config", | ||
"var_external", | ||
"var_global", | ||
"var_in_out", | ||
"var_input", | ||
"var_output", | ||
"var_stat", | ||
"var_temp", | ||
"var", | ||
"while", | ||
"word", | ||
"wstring", | ||
"xint", | ||
"xor", | ||
"xorn", | ||
"xword", | ||
"pvoid", | ||
}; | ||
protected static Regex KeywordsRegex = new Regex( | ||
@"(?<!\w)(" + string.Join("|", KeywordList) + @")(?!\w)", | ||
RegexOptions.IgnoreCase | ||
); | ||
|
||
protected static Regex SpacingRegex = new Regex(@"\s+"); | ||
|
||
public Keywords() | ||
{ | ||
} | ||
|
||
protected static string UpText(Match m) | ||
{ | ||
return m.ToString().ToUpper(); | ||
} | ||
|
||
public static string Upper(string data) | ||
{ | ||
return SpacingRegex.Replace( | ||
KeywordsRegex.Replace( | ||
data, | ||
KeywordsEval | ||
), | ||
" " | ||
); | ||
} | ||
} | ||
} |
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