本文整理汇总了C#中IdentifierTerminal.AddPrefixFlag方法的典型用法代码示例。如果您正苦于以下问题:C# IdentifierTerminal.AddPrefixFlag方法的具体用法?C# IdentifierTerminal.AddPrefixFlag怎么用?C# IdentifierTerminal.AddPrefixFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdentifierTerminal
的用法示例。
在下文中一共展示了IdentifierTerminal.AddPrefixFlag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCSharpIdentifier
public static IdentifierTerminal CreateCSharpIdentifier(string name)
{
IdentifierTerminal id = new IdentifierTerminal(name);
id.SetOption(TermOptions.CanStartWithEscape);
string strKeywords =
"abstract as base bool break byte case catch char checked " +
"class const continue decimal default delegate do double else enum event explicit extern false finally " +
"fixed float for foreach goto if implicit in int interface internal is lock long namespace " +
"new null object operator out override params private protected public " +
"readonly ref return sbyte sealed short sizeof stackalloc static string " +
"struct switch this throw true try typeof uint ulong unchecked unsafe ushort using virtual void " +
"volatile while";
id.AddKeywordList(strKeywords);
id.AddPrefixFlag("@", ScanFlags.IsNotKeyword | ScanFlags.DisableEscapes);
//From spec:
//Start char is "_" or letter-character, which is a Unicode character of classes Lu, Ll, Lt, Lm, Lo, or Nl
id.StartCharCategories.AddRange(new UnicodeCategory[] {
UnicodeCategory.UppercaseLetter, //Ul
UnicodeCategory.LowercaseLetter, //Ll
UnicodeCategory.TitlecaseLetter, //Lt
UnicodeCategory.ModifierLetter, //Lm
UnicodeCategory.OtherLetter, //Lo
UnicodeCategory.LetterNumber //Nl
});
//Internal chars
/* From spec:
identifier-part-character: letter-character | decimal-digit-character | connecting-character | combining-character |
formatting-character
*/
id.CharCategories.AddRange(id.StartCharCategories); //letter-character categories
id.CharCategories.AddRange(new UnicodeCategory[] {
UnicodeCategory.DecimalDigitNumber, //Nd
UnicodeCategory.ConnectorPunctuation, //Pc
UnicodeCategory.SpacingCombiningMark, //Mc
UnicodeCategory.NonSpacingMark, //Mn
UnicodeCategory.Format //Cf
});
//Chars to remove from final identifier
id.CharsToRemoveCategories.Add(UnicodeCategory.Format);
return id;
}
示例2: CreateScriptNetIdentifier
/// <summary>
/// Creates identifier terminal for script grammar
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
private static IdentifierTerminal CreateScriptNetIdentifier(string name)
{
IdentifierTerminal id = new IdentifierTerminal(name);
id.SetOption(TermOptions.CanStartWithEscape);
id.AddKeywords("true", "false", "null", "if", "else",
"while", "for", "foreach", "in",
"switch", "case", "default", "break",
"continue", "return", "function", "is",
"pre", "post", "invariant", "new", "using",
"global");
id.AddPrefixFlag("@", ScanFlags.IsNotKeyword | ScanFlags.DisableEscapes);
//From spec:
//Start char is "_" or letter-character, which is a Unicode character of classes Lu, Ll, Lt, Lm, Lo, or Nl
id.StartCharCategories.AddRange(new UnicodeCategory[] {
UnicodeCategory.UppercaseLetter, //Ul
UnicodeCategory.LowercaseLetter, //Ll
UnicodeCategory.TitlecaseLetter, //Lt
UnicodeCategory.ModifierLetter, //Lm
UnicodeCategory.OtherLetter, //Lo
UnicodeCategory.LetterNumber //Nl
});
//Internal chars
/* From spec:
identifier-part-character: letter-character | decimal-digit-character | connecting-character | combining-character |
formatting-character
*/
id.CharCategories.AddRange(id.StartCharCategories); //letter-character categories
id.CharCategories.AddRange(new UnicodeCategory[] {
UnicodeCategory.DecimalDigitNumber, //Nd
UnicodeCategory.ConnectorPunctuation, //Pc
UnicodeCategory.SpacingCombiningMark, //Mc
UnicodeCategory.NonSpacingMark, //Mn
UnicodeCategory.Format //Cf
});
//Chars to remove from final identifier
id.CharsToRemoveCategories.Add(UnicodeCategory.Format);
return id;
}