当前位置: 首页>>代码示例>>C#>>正文


C# IdentifierTerminal.AddPrefix方法代码示例

本文整理汇总了C#中IdentifierTerminal.AddPrefix方法的典型用法代码示例。如果您正苦于以下问题:C# IdentifierTerminal.AddPrefix方法的具体用法?C# IdentifierTerminal.AddPrefix怎么用?C# IdentifierTerminal.AddPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IdentifierTerminal的用法示例。


在下文中一共展示了IdentifierTerminal.AddPrefix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateCSharpIdentifier

 public static IdentifierTerminal CreateCSharpIdentifier(String name)
 {
     IdentifierTerminal id = new IdentifierTerminal(name, IdFlags.AllowsEscapes | IdFlags.CanStartWithEscape);
       id.AddPrefix("@", IdFlags.IsNotKeyword);
       //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;
 }
开发者ID:TheByte,项目名称:sones,代码行数:31,代码来源:TerminalFactory.cs

示例2: CreateIdentifier

        private IdentifierTerminal CreateIdentifier(string name)
        {
            var term = new IdentifierTerminal(name);
            term.AddPrefix("@", IdOptions.IsNotKeyword);

            term.StartCharCategories.AddRange(new UnicodeCategory[] {
                UnicodeCategory.LowercaseLetter,
                UnicodeCategory.UppercaseLetter,
                UnicodeCategory.TitlecaseLetter,
                UnicodeCategory.ModifierLetter,
                UnicodeCategory.OtherLetter,
                UnicodeCategory.LetterNumber
            });

            term.CharCategories.AddRange(term.StartCharCategories);
            term.CharCategories.AddRange(new UnicodeCategory[] {
                UnicodeCategory.DecimalDigitNumber
            });

            term.CharsToRemoveCategories.Add(UnicodeCategory.Format);
            return term;
        }
开发者ID:Karapuska,项目名称:Totem,代码行数:22,代码来源:TotemGrammar.Literals.cs

示例3: SeeNoSQLGrammar

        public SeeNoSQLGrammar()
            : base(false)
        {
            //Terminals
            var lineComment = new CommentTerminal("LINE_COMMENT", "//", "\n", "\r\n");
            var blockComment = new CommentTerminal("BLOCK_COMMENT", "/*", "*/");
            NonGrammarTerminals.Add(lineComment);
            NonGrammarTerminals.Add(blockComment);

            var number = new NumberLiteral("number");
            var intVal = new NumberLiteral("integer", NumberOptions.IntOnly);
            var stringLiteral = new StringLiteral("string", "'", StringOptions.AllowsDoubledQuote);
            var id = new IdentifierTerminal("id") {Priority = Terminal.HighestPriority};
            var param = new IdentifierTerminal("param");
            param.AddPrefix("@",IdOptions.None);
            param.Priority = Terminal.LowestPriority;
            var constantTerminal = new ConstantTerminal("constantTerminal");
            constantTerminal.Add("true", true);
            constantTerminal.Add("false", false);
            constantTerminal.Add("null", null);
            constantTerminal.Add("MAX_STRING", new object());
            constantTerminal.Add("MIN_STRING", null);
            constantTerminal.Priority = Terminal.HighestPriority;

            var ALL = ToTerm("ALL");
            var ALLOW_STALE = ToTerm("ALLOW_STALE");
            var AND = ToTerm("AND");
            var BETWEEN = ToTerm("BETWEEN");
            var COMMA = ToTerm(",");
            var DESCENDING = ToTerm("DESCENDING");
            var DOCUMENT = ToTerm("DOCUMENT");
            var FALSE = ToTerm("false");
            var FROM = ToTerm("FROM");
            var GROUP = ToTerm("GROUP");
            var GROUP_LEVEL = ToTerm("GROUP_LEVEL");
            var IN = ToTerm("IN");
            var INCLUDE_DOCS = ToTerm("INCLUDE_DOCS");
            var INCLUSIVE_END = ToTerm("INCLUSIVE_END");
            var KEY = ToTerm("KEY");
            var LIMIT = ToTerm("LIMIT");
            var OR = ToTerm("OR");
            var QUERYOPTIONS = ToTerm("QUERYOPTIONS");
            var REDUCE = ToTerm("REDUCE");
            var SKIP = ToTerm("SKIP");
            var TRUE = ToTerm("true");
            var UNION = ToTerm("UNION");
            var USING = ToTerm("USING");
            var VIEW = ToTerm("VIEW");
            var WHERE = ToTerm("WHERE");
            var WITH = ToTerm("WITH");

            //Non-terminals
            var betweenStatement = new NonTerminal("between");
            var binExpr = new NonTerminal("binExpr");
            var binOp = new NonTerminal("binOp");
            var constOperand = new NonTerminal("constOperand");
            var documentStatement = new NonTerminal("documentStatement");
            var expression = new NonTerminal("expression");
            var fromStatement = new NonTerminal("from");
            var keyArrayStatement = new NonTerminal("keyArray");
            var keyList = new NonTerminal("keys");
            var keyObjectStatement = new NonTerminal("keyObject");
            var keyValueStatement = new NonTerminal("keyValue");
            var keyStatement = new NonTerminal("key");
            var query = new NonTerminal("query");
            var queryOption = new NonTerminal("queryOption");
            var queryOptionList = new NonTerminal("queryOptionList");
            var queryOptions = new NonTerminal("queryOptions");
            var stmt = new NonTerminal("stmt");
            var unionStatement = new NonTerminal("unionStatement");
            var term = new NonTerminal("term");
            var view = new NonTerminal("view");
            var whereStatement = new NonTerminal("where");


            //Rules
            this.Root = query;
            query.Rule = MakePlusRule(query, unionStatement, stmt);
            stmt.Rule = fromStatement + queryOptions + keyStatement + whereStatement | fromStatement + queryOptions;
            unionStatement.Rule = UNION + ALL;

            term.Rule = id | stringLiteral | number | param | constOperand;
            binOp.Rule = ToTerm("=") | ">" | "<" | ">=" | "<=" | AND | OR | IN | BETWEEN;
            binExpr.Rule = expression + binOp + expression;
            expression.Rule = term | binExpr | betweenStatement | "(" + expression + ")";

            constOperand.Rule = constantTerminal;
            view.Rule = VIEW + "(" + id + COMMA + id + ")";
            queryOptions.Rule = Empty | USING + QUERYOPTIONS + "(" + queryOptionList + ")";
            queryOption.Rule = ALLOW_STALE + binOp + constOperand | DESCENDING + binOp + constOperand | GROUP + binOp + constOperand |
                               GROUP_LEVEL + binOp + intVal | INCLUDE_DOCS + binOp + constOperand | INCLUSIVE_END + binOp + constOperand |
                               LIMIT + binOp + intVal | REDUCE + binOp + constOperand | SKIP + binOp + intVal;
            queryOptionList.Rule = MakePlusRule(queryOptionList, COMMA, queryOption);
            fromStatement.Rule = FROM + view | FROM + documentStatement;
            documentStatement.Rule = DOCUMENT + "(" + term + ")";

            keyStatement.Rule = keyArrayStatement | keyObjectStatement | keyValueStatement;
            keyArrayStatement.Rule = WITH + KEY + "[" + keyList + "]";
            keyObjectStatement.Rule = WITH + KEY + "{" + keyList + "}";
            keyValueStatement.Rule = WITH + KEY + id;
//.........这里部分代码省略.........
开发者ID:ifandelse,项目名称:CouchRS,代码行数:101,代码来源:SeeNoSQLGrammar.cs


注:本文中的IdentifierTerminal.AddPrefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。