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


C# IdentifierTerminal.Q方法代码示例

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


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

示例1: RubyGrammar

        public RubyGrammar()
        {
            #region Terminals
              //String Literals with single and double-quote start/end symbols
              StringLiteral STRING = new StringLiteral("STRING", TermOptions.SpecialIgnoreCase);
              STRING.AddStartEnd("\"", ScanFlags.None);
              STRING.AddStartEnd("'", ScanFlags.None);
              Terminal HereDoc = new Terminal("HereDoc"); //-- implement me!
              Terminal RegExLiteral = new Terminal("RegExLiteral"); //-- implement me!
              IdentifierTerminal IDENTIFIER = new IdentifierTerminal("identifier", "_!?", "[email protected]");
              //                                                name     extraChars      extraFirstChars
              IDENTIFIER.DisplayName = "variable";
              //we need to isolate reserved words to avoid ambiguities in grammar
              IDENTIFIER.AddKeywords("do", "end", "def", "class",
                                       "if", "case", "return", "yield", "while", "until");  //and some others...
              Terminal Number = new NumberLiteral("Number");
              Terminal Comment = new CommentTerminal("Comment", "#", "\n");
              NonGrammarTerminals.Add(Comment); //add comment explicitly to this list as it is not reachable from Root

              //some conveniency variables
              Terminal Pipe = Symbol("|");
              Terminal dot = Symbol(".");
              Terminal comma = Symbol(",");
              #endregion

              #region NonTerminals
              //NT variables names match element names in original grammar
              NonTerminal PROGRAM = new NonTerminal("PROGRAM");
              NonTerminal COMPSTMT = new NonTerminal("COMPSTMT");
              NonTerminal STMT = new NonTerminal("STMT");
              NonTerminal BLOCK = new NonTerminal("BLOCK");
              NonTerminal EXPR = new NonTerminal("EXPR");
              //NonTerminal CALL = new NonTerminal("CALL");
              NonTerminal COMMAND = new NonTerminal("COMMAND");
              NonTerminal FUNCTION = new NonTerminal("FUNCTION");
              NonTerminal ARG = EXPR;// new NonTerminal("ARG");
              NonTerminal PRIMARY = new NonTerminal("PRIMARY", "operand");
              NonTerminal WHEN_ARGS = new NonTerminal("WHEN_ARGS");
              NonTerminal THEN = new NonTerminal("THEN");
              NonTerminal BLOCK_BEGIN = new NonTerminal("BLOCK_BEGIN");
              NonTerminal BLOCK_END = new NonTerminal("BLOCK_END");
              NonTerminal BLOCK_VAR = new NonTerminal("BLOCK_VAR");
            //      NonTerminal MLHS_ITEM = new NonTerminal("MLHS_ITEM");
              NonTerminal LHS = new NonTerminal("LHS");
              NonTerminal MRHS = new NonTerminal("MRHS");
            //      NonTerminal MLHS = MRHS; // new NonTerminal("MLHS");
              NonTerminal CALL_ARGS = new NonTerminal("CALL_ARGS");
              NonTerminal CALL_ARGS_P = new NonTerminal("CALL_ARGS_P");
              NonTerminal AMP_ARG = new NonTerminal("AMP_ARG");
              NonTerminal STAR_ARG = new NonTerminal("STAR_ARG");
              NonTerminal ARGS = new NonTerminal("ARGS");
              NonTerminal ARGDECL = new NonTerminal("ARGDECL");
              NonTerminal ARGLIST = new NonTerminal("ARGLIST");
            //      NonTerminal SINGLETON = new NonTerminal("SINGLETON");
              NonTerminal ASSOCS = new NonTerminal("ASSOCS");
              NonTerminal ASSOC = new NonTerminal("ASSOC");
            //      NonTerminal VARIABLE = new NonTerminal("VARIABLE");  --merged into IDENTIFIER
              NonTerminal LITERAL = new NonTerminal("LITERAL", "value");
              NonTerminal TERM = new NonTerminal("TERM");
              NonTerminal DO = new NonTerminal("DO");
            //      NonTerminal VARNAME = new NonTerminal("VARNAME");   // note 1
              NonTerminal GLOBAL = new NonTerminal("GLOBAL");
              NonTerminal RETURN_STMT = new NonTerminal("RETURN_STMT");
              NonTerminal YIELD_STMT = new NonTerminal("YIELD_STMT");
              NonTerminal DEFINEDQ_STMT = new NonTerminal("DEFINEDQ_STMT");
              NonTerminal FUNCTION_STMT = new NonTerminal("FUNCTION_STMT");
              NonTerminal IF_STMT = new NonTerminal("IF_STMT");
              NonTerminal UNLESS_STMT = new NonTerminal("UNLESS_STMT");
              NonTerminal WHILE_STMT = new NonTerminal("WHILE_STMT");
              NonTerminal UNTIL_STMT = new NonTerminal("UNTIL_STMT");
              NonTerminal CASE_STMT = new NonTerminal("CASE_STMT");
              NonTerminal FOR_STMT = new NonTerminal("FOR_STMT");
              NonTerminal BLOCK_STMT = new NonTerminal("BLOCK_STMT");
              NonTerminal CLASS_DEF = new NonTerminal("CLASS_DEF");
              NonTerminal BASE_REF = new NonTerminal("BASE_REF");
              NonTerminal MODULE = new NonTerminal("MODULE_STMT");
              NonTerminal DEFFUNC_STMT = new NonTerminal("DEFFUNC_STMT");
              NonTerminal DEFSING_STMT = new NonTerminal("DEFSING_STMT");
              NonTerminal SINGLETON = new NonTerminal("SINGLETON");
              NonTerminal END = new NonTerminal("end");

              NonTerminal SYMBOL = new NonTerminal("SYMBOL");
              //Not in original grammar
              NonTerminal FNAME = new NonTerminal("FNAME");
              BLOCK_BEGIN.Rule = Symbol("do") | "{";
              BLOCK_END.Rule = Symbol("end") | "}";
              NonTerminal OPERATION = new NonTerminal("OPERATION");
              //      Terminal VARNAME = IDENTIFIER;
              NonTerminal AUG_ASGN = new NonTerminal("AUG_ASGN");
              NonTerminal BINOP = new NonTerminal("BINOP", "operator");
              NonTerminal UNOP = new NonTerminal("UNOP");
              NonTerminal DELIM = new NonTerminal("DELIM");

              #endregion

              #region Rules
              //Set grammar root
              this.Root = PROGRAM;

              //PROGRAM         : COMPSTMT
//.........这里部分代码省略.........
开发者ID:TheByte,项目名称:sones,代码行数:101,代码来源:RubyGrammar.cs


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