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


C# NonTerminal.Q方法代码示例

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


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

示例1: SchemeGrammar


//.........这里部分代码省略.........
      var DefineVarForm = new NonTerminal("DefineVarForm");
      var DefineFunForm = new NonTerminal("DefineFunForm");
      var LambdaForm = new NonTerminal("LambdaForm");
      var IfForm = new NonTerminal("IfForm");
      var CondForm = new NonTerminal("CondForm");
      var CondClause = new NonTerminal("CondClause");
      var CondClauseList = new NonTerminal("CondClauseList");
      var CondElseOpt = new NonTerminal("CondElseOpt");
      var BeginForm = new NonTerminal("BeginForm");
      var LetForm = new NonTerminal("LetForm"); //not implemented
      var LetRecForm = new NonTerminal("LetRecForm"); //not implemented
      var LetPair = new NonTerminal("LetPair");
      var LetPairList = new NonTerminal("LetPairList");
      #endregion

      #region Rules
      base.Root = Module; 

      LP.Rule = ToTerm("(") | "[";  //R6RS allows mix & match () and []
      RP.Rule = ToTerm(")") | "]";

      // Module.Rule = LibraryListOpt + Script; -- this brings conflicts
      Module.Rule = LibraryList + Script | Script;
      LibraryList.Rule = MakePlusRule(LibraryList, Library);
      Script.Rule = ImportSection + DatumList | DatumList; 

      //Library
      // the following doesn't work - brings conflicts that incorrectly resolved by default shifting
      //Library.Rule = LP + "library" + LibraryName + ExportSectionOpt + ImportSectionOpt + DatumListOpt + RP;
      Library.Rule = LP + "library" + LibraryName + LibraryBody + RP;
      //Note - we should be using DatumListOpt, but that brings 2 conflicts, so for now it is just DatumList
      //Note that the following style of BNF expressions is strongly discouraged - all productions should be of the same length, 
      // so that the process of mapping child nodes to parent's properties is straightforward.
      LibraryBody.Rule = ExportSection + ImportSection + DatumList
                       | ExportSection + DatumList
                       | ImportSection + DatumList
                       | DatumList; 
      LibraryName.Rule = LP + IdentifierList + LibraryVersion.Q() + RP;
      LibraryVersion.Rule = LP + VersionListOpt + RP; //zero or more subversion numbers
      VersionListOpt.Rule = MakeStarRule(VersionListOpt, Number);
      ExportSection.Rule = LP + "export" + ExportSpecList + RP;
      ImportSection.Rule = LP + "import" + ImportSpecList + RP;
      ExportSpecList.Rule = MakePlusRule(ExportSpecList, ExportSpec);
      ImportSpecList.Rule = MakePlusRule(ImportSpecList, ImportSpec);
      ExportSpec.Rule = Identifier | LP + "rename"  +  LP + Identifier + Identifier + RP + RP;
      ImportSpec.Rule = LP + Identifier + RP;   // - much more complex in R6RS

      //Datum
      Datum.Rule = Atom | CompoundDatum;
      DatumOpt.Rule = Empty | Datum;
      DatumList.Rule = MakePlusRule(DatumList, Datum);
      DatumListOpt.Rule = MakeStarRule(DatumListOpt, Datum);
      Atom.Rule = Number | Identifier | stringLiteral | Constant | charLiteral | ".";
      CompoundDatum.Rule = Statement | Abbreviation | Vector | ByteVector;
      Identifier.Rule = SimpleIdentifier | PeculiarIdentifier;
      IdentifierList.Rule = MakePlusRule(IdentifierList, Identifier);
      IdentifierListOpt.Rule = MakeStarRule(IdentifierListOpt, Identifier);

      //TODO: create PeculiarIdentifier custom terminal instead of var 
      // or just custom SchemeIdentifier terminal
      PeculiarIdentifier.Rule = ToTerm("+") | "-" | "..."; // |"->" + subsequent; (should be!) 
      Abbreviation.Rule = AbbrevPrefix + Datum;
      AbbrevPrefix.Rule = ToTerm("'") | "`" | ",@" | "," | "#'" | "#`" | "#,@" | "#,";
      Vector.Rule = "#(" + DatumListOpt + ")";
      ByteVector.Rule = "#vu8(" + ByteList + ")";
      ByteList.Rule = MakeStarRule(ByteList, Byte);

      Statement.Rule = FunctionCall | SpecialForm;

      FunctionCall.Rule = LP + FunctionRef + DatumListOpt + RP;
      FunctionRef.Rule = Identifier | Statement;

      SpecialForm.Rule = DefineVarForm | DefineFunForm | LambdaForm | IfForm | CondForm | BeginForm | LetForm | LetRecForm;
      DefineVarForm.Rule = LP + "define" + Identifier + Datum + RP;
      DefineFunForm.Rule = LP + "define" + LP + Identifier + IdentifierListOpt + RP + DatumList + RP;
      LambdaForm.Rule = LP + "lambda" + LP + IdentifierListOpt + RP + DatumList + RP;
      IfForm.Rule = LP + "if" + Datum + Datum + DatumOpt + RP;

      CondForm.Rule = LP + "cond" + CondClauseList + CondElseOpt + RP;
      CondClauseList.Rule = MakePlusRule(CondClauseList, CondClause);
      CondClause.Rule = LP + Datum + DatumList + RP;
      CondElseOpt.Rule = Empty | LP + "else" + DatumList + RP;
      LetForm.Rule = LP + "let" + LP + LetPairList + RP + DatumList + RP;
      LetRecForm.Rule = LP + "letrec" + LP + LetPairList + RP + DatumList + RP;
      BeginForm.Rule = LP + "begin" + DatumList + RP;
      LetPairList.Rule = MakePlusRule(LetPairList, LetPair);
      LetPair.Rule = LP + Identifier + Datum + RP;
      #endregion 

      //Register brace  pairs
      RegisterBracePair("(", ")"); 
      RegisterBracePair("[", "]");

      MarkPunctuation(LP, RP);
      MarkTransient(Datum, CompoundDatum, Statement, SpecialForm, Atom); 

      //Scheme is tail-recursive language
      base.LanguageFlags |= LanguageFlags.TailRecursive; 

    }//constructor
开发者ID:mtashkinov,项目名称:YaccConstructor,代码行数:101,代码来源:SchemeGrammar.cs

示例2: TerminalSet


//.........这里部分代码省略.........
              #endregion
             */

              // RULES
              //B.2.1. Basic concepts
              //qual_name_with_targs is an alias for namespace-name, namespace-or-type-name, type-name,

              generic_dimension_specifier.Rule = gen_lt + commas_opt + ">";
              qual_name_segments_opt.Rule = MakeStarRule(qual_name_segments_opt, null, qual_name_segment);
              identifier_or_builtin.Rule = identifier | builtin_type;
              identifier_ext.Rule = identifier_or_builtin | "this" | "base";
              qual_name_segment.Rule = dot + identifier
                              | "::" + identifier
                              | type_argument_list;
              //generic_dimension_specifier.Rule = lt + commas_opt + ">";
              generic_dimension_specifier.Rule = gen_lt + commas_opt + ">";
              qual_name_with_targs.Rule = identifier_or_builtin + qual_name_segments_opt;

              type_argument_list.Rule = gen_lt + type_ref_list + ">";
              type_argument_list_opt.Rule = Empty | type_argument_list;
              typearg_or_gendimspec_list.Rule = type_argument_list | generic_dimension_specifier_opt;

              //B.2.2. Types
              type_or_void.Rule = qual_name_with_targs | "void";
              builtin_type.Rule = integral_type | "bool" | "decimal" | "float" | "double" | "string" | "object";

              type_ref.Rule = type_or_void + qmark_opt + rank_specifiers_opt + typearg_or_gendimspec_list;
              type_ref_list.Rule = MakePlusRule(type_ref_list, comma, type_ref);

              var comma_list_opt = new NonTerminal("comma_list_opt");
              comma_list_opt.Rule = MakeStarRule(comma_list_opt, comma);
              rank_specifier.Rule = "[" + comma_list_opt + "]";
              rank_specifiers.Rule = MakePlusRule(rank_specifiers, null, rank_specifier);
              rank_specifiers_opt.Rule = rank_specifiers.Q();
              integral_type.Rule = ToTerm("sbyte") | "byte" | "short" | "ushort" | "int" | "uint" | "long" | "ulong" | "char";

              //B.2.4. Variables
              //Quite strange in specs -
              //  variable-reference:
              //     expression
              // Is that case it would be possible to do the following:
              //                 GetMyStuff(out (a+b));
              //  but MS c# rejects it

              //B.2.4. Expressions
              argument.Rule = expression | "ref" + identifier | "out" + identifier;
              argument_list.Rule = MakePlusRule(argument_list, comma, argument);
              argument_list_opt.Rule = Empty | argument_list;
              expression.Rule = conditional_expression
                    | bin_op_expression
                    | typecast_expression
                    | primary_expression;
              expression_opt.Rule = Empty | expression;
              expression_list.Rule = MakePlusRule(expression_list, comma, expression);
              unary_operator.Rule = ToTerm("+") | "-" | "!" | "~" | "*";
              assignment_operator.Rule = ToTerm("=") | "+=" | "-=" | "*=" | "/=" | "%=" | "&=" | "|=" | "^=" | "<<=" | ">>=";
              conditional_expression.Rule = expression + PreferShiftHere() + qmark + expression + colon + expression;// + ReduceThis();
              bin_op_expression.Rule = expression + bin_op + expression;

              typecast_expression.Rule = parenthesized_expression + primary_expression;
              primary_expression.Rule =
            literal
            | unary_expression
            | parenthesized_expression
            | member_access
            | pre_incr_decr_expression
开发者ID:201123065,项目名称:Irony,代码行数:67,代码来源:CSharpGrammar.cs

示例3: LuaGrammar

        public LuaGrammar()
            : base(true)
        {
            #region Declare Terminals Here
            StringLiteral STRING = CreateLuaString("string");
            NumberLiteral NUMBER = CreateLuaNumber("number");

            LuaLongStringTerminal LONGSTRING = new LuaLongStringTerminal("long-string");

            // This includes both single-line and block comments
            var Comment = new LuaCommentTerminal("block-comment");

            //  Regular Operators

            //  Member Select Operators
            var DOT = Operator(".");
            DOT.EditorInfo = new TokenEditorInfo(TokenType.Operator, TokenColor.Text, TokenTriggers.MemberSelect);

            var COLON = Operator(":");
            COLON.EditorInfo = new TokenEditorInfo(TokenType.Operator, TokenColor.Text, TokenTriggers.MemberSelect);

            //  Standard Operators
            var EQ = Operator("=");

            //yujiang: Ignore comment
            NonGrammarTerminals.Add(Comment);

            #region Keywords
            var LOCAL = Keyword("local");
            var DO = Keyword("do");
            var END = Keyword("end");
            var WHILE = Keyword("while");
            var REPEAT = Keyword("repeat");
            var UNTIL = Keyword("until");
            var IF = Keyword("if");
            var THEN = Keyword("then");
            var ELSEIF = Keyword("elseif");
            var ELSE = Keyword("else");
            var FOR = Keyword("for");
            var IN = Keyword("in");
            var FUNCTION = Keyword("function");
            var RETURN = Keyword("return");
            var BREAK = Keyword("break");
            var NIL = Keyword("nil");
            var FALSE = Keyword("false");
            var TRUE = Keyword("true");
            var NOT = Keyword("not");
            var AND = Keyword("and");
            var OR = Keyword("or");
            #endregion
            IdentifierTerminal Name = new IdentifierTerminal("identifier");

             #endregion

            #region Declare NonTerminals Here
            NonTerminal Chunk = new NonTerminal("chunk");
            NonTerminal Block = new NonTerminal("block");

            NonTerminal Statement = new NonTerminal("statement");
            NonTerminal LastStatement = new NonTerminal("last statement");
            NonTerminal FuncName = new NonTerminal("function name");
            NonTerminal VarList = new NonTerminal("var list");
            NonTerminal Var = new NonTerminal("var");
            NonTerminal NameList = new NonTerminal("name list");
            NonTerminal ExprList = new NonTerminal("expr list");
            NonTerminal Expr = new NonTerminal("expr");
            NonTerminal PrefixExpr = new NonTerminal("prefix expr");
            NonTerminal FunctionCall = new NonTerminal("function call");
            NonTerminal Args = new NonTerminal("args");
            NonTerminal NamedFunction = new NonTerminal("named function");
            NonTerminal NamelessFunction = new NonTerminal("nameless function");
            NonTerminal FuncBody = new NonTerminal("function body");
            NonTerminal ParList = new NonTerminal("parlist");
            NonTerminal TableConstructor = new NonTerminal("table constructor");
            NonTerminal FieldList = new NonTerminal("field list");
            NonTerminal Field = new NonTerminal("field");
            NonTerminal FieldSep = new NonTerminal("field seperator");
            NonTerminal BinOp = new NonTerminal("binop");
            NonTerminal UnOp = new NonTerminal("unop");

            #endregion

            #region Place Rules Here
            //Using Lua 5.1 grammar as defined in
            //http://www.lua.org/manual/5.1/manual.html#8
            this.Root = Chunk;

            //chunk ::= {stat [`;´]} [laststat [`;´]]
            Chunk.Rule = (Statement + ToTerm(";").Q()).Star() + (LastStatement + ToTerm(";").Q()).Q();

            //block ::= chunk
            Block = Chunk;

            //stat ::=  varlist `=´ explist |
            //     functioncall |
            //     do block end |
            //     while exp do block end |
            //     repeat block until exp |
            //     if exp then block {elseif exp then block} [else block] end |
            //     for Name `=´ exp `,´ exp [`,´ exp] do block end |
//.........这里部分代码省略.........
开发者ID:guillaume86,项目名称:vsLua,代码行数:101,代码来源:LuaGrammer.cs

示例4: LuaGrammar

        private LuaGrammar() :
            base(true)
        {
            #region Declare Terminals Here
            StringLiteral STRING = CreateLuaString(LuaTerminalNames.String);
            NumberLiteral NUMBER = CreateLuaNumber(LuaTerminalNames.Number);

            LuaLongStringTerminal LONGSTRING = new LuaLongStringTerminal(LuaTerminalNames.LongString);

            // This includes both single-line and block comments
            var Comment = new LuaCommentTerminal(LuaTerminalNames.Comment);

            //  Regular Operators
            var DOT = ToTerm(LuaTerminalNames.Dot);
            var COLON = ToTerm(LuaTerminalNames.Colon);
            var SEMIC = ToTerm(LuaTerminalNames.Semic);
            var COMMA = ToTerm(LuaTerminalNames.Comma);

            //  Standard Operators
            var EQ = Operator(LuaTerminalNames.Equal);

            var OpeAdd = Operator("+");
            var OpeSub = Operator("-");
            var OpeMul = Operator("*");
            var OpeDiv = Operator("/");
            var OpePow = Operator("^");

            var OpeEQ = Operator("==");
            var OpeNEQ = Operator("~=");
            var OpeBig = Operator(">");
            var OpeBigEQ = Operator(">=");
            var OpeSm = Operator("<");
            var OpeSmEQ = Operator("<=");

            var OpeLink = Operator("..");

            var OpePre = Operator("%");
            var OpeWell = Operator("#");

            NonGrammarTerminals.Add(Comment);

            #region Keywords
            var LOCAL = Keyword("local");
            var DO = Keyword("do");
            var END = Keyword("end");
            var WHILE = Keyword("while");
            var REPEAT = Keyword("repeat");
            var UNTIL = Keyword("until");
            var IF = Keyword("if");
            var THEN = Keyword("then");
            var ELSEIF = Keyword("elseif");
            var ELSE = Keyword("else");
            var FOR = Keyword("for");
            var IN = Keyword("in");
            var FUNCTION = Keyword("function");
            var RETURN = Keyword("return");
            var BREAK = Keyword("break");
            var NIL = Keyword("nil");
            var FALSE = Keyword("false");
            var TRUE = Keyword("true");
            var NOT = Keyword("not");
            var AND = Keyword("and");
            var OR = Keyword("or");

            //var CLASS = Keyword("class");
            //var NEW = Keyword("new");
            #endregion
            IdentifierTerminal Name = new IdentifierTerminal(LuaTerminalNames.Identifier);

            #endregion

            #region Declare NonTerminals Here
            NonTerminal Chunk = new NonTerminal(LuaTerminalNames.Chunk);
            NonTerminal Block = new NonTerminal(LuaTerminalNames.Block);

            NonTerminal Statement = new NonTerminal(LuaTerminalNames.Statement);
            NonTerminal LastStatement = new NonTerminal(LuaTerminalNames.LastStatement);
            NonTerminal FuncName = new NonTerminal(LuaTerminalNames.FunctionName);
            NonTerminal VarList = new NonTerminal(LuaTerminalNames.VarList);
            NonTerminal Var = new NonTerminal(LuaTerminalNames.Var);
            NonTerminal NameList = new NonTerminal(LuaTerminalNames.NameList);
            NonTerminal ExprList = new NonTerminal(LuaTerminalNames.ExprList);
            NonTerminal Expr = new NonTerminal(LuaTerminalNames.Expr);
            NonTerminal PrefixExpr = new NonTerminal(LuaTerminalNames.PrefixExpr);
            NonTerminal FunctionCall = new NonTerminal(LuaTerminalNames.FunctionCall);
            NonTerminal Args = new NonTerminal(LuaTerminalNames.Args);
            NonTerminal NamedFunction = new NonTerminal(LuaTerminalNames.NamedFunction);
            NonTerminal NamelessFunction = new NonTerminal(LuaTerminalNames.NamelessFunction);
            NonTerminal FuncBody = new NonTerminal(LuaTerminalNames.FunctionBody);
            NonTerminal ParList = new NonTerminal(LuaTerminalNames.ParList);
            NonTerminal TableConstructor = new NonTerminal(LuaTerminalNames.TableConstructor);
            NonTerminal FieldList = new NonTerminal(LuaTerminalNames.FieldList);
            NonTerminal Field = new NonTerminal(LuaTerminalNames.Field);
            NonTerminal FieldSep = new NonTerminal(LuaTerminalNames.FieldSeperator);
            NonTerminal BinOp = new NonTerminal(LuaTerminalNames.Binop);
            NonTerminal UnOp = new NonTerminal(LuaTerminalNames.Unop);

            NonTerminal LoopBlock = new NonTerminal(LuaTerminalNames.LoopBlock);
            NonTerminal BranchBlock = new NonTerminal(LuaTerminalNames.BranchBlock);
            NonTerminal Assign = new NonTerminal(LuaTerminalNames.Assign);
//.........这里部分代码省略.........
开发者ID:peterdocter,项目名称:BabeLua,代码行数:101,代码来源:LuaGrammar.cs

示例5: TerminalSet


//.........这里部分代码省略.........
             */

            // RULES
            //B.2.1. Basic concepts
            //qual_name_with_targs is an alias for namespace-name, namespace-or-type-name, type-name,

            generic_dimension_specifier.Rule = lt + commas_opt + ">";
            identifier_ext.Rule = identifier_or_builtin | "this" | "base";
            generic_dimension_specifier.Rule = lt + commas_opt + ">";

            builtin_type.Rule = integral_type | "bool" | "decimal" | "float" | "double" | "string" | "object" ;

            qual_name_segments_opt.Rule = MakeStarRule(qual_name_segments_opt, null, qual_name_segment);
            qual_name_segment.Rule = dot + identifier
                                    | "::" + identifier
                                    | type_argument_list;

            qual_name_with_targs.Rule = identifier_or_builtin + qual_name_segments_opt | xlang_type_choice ;
            identifier_or_builtin.Rule = identifier | builtin_type ;

            type_argument_list.Rule = lt + type_ref_list + ">";
            type_argument_list_opt.Rule = Empty | type_argument_list;

            //B.2.2. Types
            type_or_void.Rule = qual_name_with_targs | "void";

            type_ref.Rule = type_or_void + qmark_opt + rank_specifiers_opt + generic_dimension_specifier_opt;
            type_ref_list.Rule = MakePlusRule(type_ref_list, comma, type_ref);

            var comma_list_opt = new NonTerminal("comma_list?");
            comma_list_opt.Rule = MakeStarRule(comma_list_opt, comma);
            rank_specifier.Rule = "[" + comma_list_opt + "]";
            rank_specifiers.Rule = MakePlusRule(rank_specifiers, null, rank_specifier);
            rank_specifiers_opt.Rule = rank_specifiers.Q();
            integral_type.Rule = ToTerm("sbyte") | "byte" | "short" | "ushort" | "int" | "uint" | "long" | "ulong" | "char";

            //B.2.4. Variables
            //Quite strange in specs -
            //  variable-reference:
            //     expression
            // Is that case it would be possible to do the following:
            //                 GetMyStuff(out (a+b));
            //  but MS c# rejects it

            //B.2.4. Expressions
            argument.Rule = expression | "ref" + identifier | "out" + identifier;
            argument_list.Rule = MakePlusRule(argument_list, comma, argument);
            argument_list_opt.Rule = Empty | argument_list;
            expression.Rule = conditional_expression
                          | bin_op_expression
                          | typecast_expression
                          | primary_expression;
            expression_opt.Rule = Empty | expression;
            expression_list.Rule = MakePlusRule(expression_list, comma, expression);
            unary_operator.Rule = ToTerm("+") | "-" | "!" | "~" | "*";
            assignment_operator.Rule = ToTerm("=") | "+=" | "-=" | "*=" | "/=" | "%=" | "&=" | "|=" | "^=" | "<<=" | ">>=";
            conditional_expression.Rule = expression + PreferShiftHere() + qmark + expression + colon + expression;// + ReduceThis();
            bin_op_expression.Rule = expression + bin_op + expression;

            typecast_expression.Rule = parenthesized_expression + primary_expression;

            primary_expression.Rule =                                               literal |
                                                                                    unary_operator + primary_expression |
                                                                                    parenthesized_expression |
                                                                                    member_access|
                                                                                    pre_incr_decr_expression |
开发者ID:gvdwiele,项目名称:XLANGrammar,代码行数:67,代码来源:XLANGsGrammar.cs

示例6: Grammar

      public Grammar() {
        #region 1. Terminals
        NumberLiteral n = TerminalFactory.CreateCSharpNumber("number");
        StringLiteral stringLiteral = TerminalFactory.CreateCSharpString("String");

        IdentifierTerminal ident = new IdentifierTerminal("Identifier");
        this.MarkReservedWords(
          "assert", "assume", "axiom",
          "bool", "break",
          "bv0", "bv1", "bv2", "bv3", "bv4", "bv5", "bv6", "bv7", "bv8", "bv9",
          "bv10", "bv11", "bv12", "bv13", "bv14", "bv15", "bv16", "bv17", "bv18", "bv19",
          "bv20", "bv21", "bv22", "bv23", "bv24", "bv25", "bv26", "bv27", "bv28", "bv29",
          "bv30", "bv31", "bv32",
          "bv64",
          "call", "complete", "const",
          "div",
          "else", "ensures", "exists", "extends",
          "false", "forall", "free", "function",
          "goto",
          "havoc",
          "if", "implementation", "int", "invariant",
          "lambda",
          "mod", "modifies",
          "old",
          "procedure",
          "real", "requires", "return", "returns",
          "then", "true", "type",
          "unique",
          "var",
          "where", "while"
          );

        StringLiteral s = new StringLiteral("String", "'", StringFlags.AllowsDoubledQuote);

        Terminal dot = ToTerm(".", "dot");
        Terminal less = ToTerm("<");
        Terminal greater = ToTerm(">");
        Terminal iff = ToTerm("<==>");
        Terminal implication = ToTerm("==>");
        Terminal explication = ToTerm("<==");
        Terminal LBracket = ToTerm("[");
        Terminal RBracket = ToTerm("]");
        Terminal LParen = ToTerm("(");
        Terminal RParen = ToTerm(")");
        Terminal RCurly = ToTerm("}");
        Terminal LCurly = ToTerm("{");
        Terminal LDoubleCurly = ToTerm("{{");
        Terminal RDoubleCurly = ToTerm("}}");
        Terminal comma = ToTerm(",");
        Terminal semicolon = ToTerm(";");
        Terminal colon = ToTerm(":");
        Terminal doubleColon = ToTerm("::");

        #endregion

        #region 2. Non-terminals
        #region 2.1 Expressions
        NonTerminal expression = new NonTerminal("Expr");
        NonTerminal BinOp = new NonTerminal("BinOp");
        NonTerminal LUnOp = new NonTerminal("LUnOp");
        NonTerminal RUnOp = new NonTerminal("RUnOp");

        NonTerminal ArrayConstructor = new NonTerminal("ArrayConstructor");
        #endregion

        #region 2.2 QualifiedName
        //Expression List:  expr1, expr2, expr3, ..
        NonTerminal expressionList = new NonTerminal("ExprList");
        NonTerminal identList = new NonTerminal("identList");
        //A name in form: a.b.c().d[1,2].e ....
        NonTerminal NewStmt = new NonTerminal("NewStmt");
        NonTerminal NewArrStmt = new NonTerminal("NewArrStmt");
        NonTerminal QualifiedName = new NonTerminal("QualifiedName");
        NonTerminal GenericsPostfix = new NonTerminal("GenericsPostfix");
        NonTerminal ArrayExpression = new NonTerminal("ArrayExpression");
        NonTerminal FunctionExpression = new NonTerminal("FunctionExpression");
        NonTerminal selectExpr = new NonTerminal("selectExpr");
        #endregion

        #region 2.3 Statement
        NonTerminal Condition = new NonTerminal("Condition");

        NonTerminal Statement = new NonTerminal("Statement");
        NonTerminal Statements = new NonTerminal("Statements");

        //Block
        NonTerminal blockStatement = new NonTerminal("CompoundStatement");
        #endregion

        #region 2.4 Program and Functions
        NonTerminal Prog = new NonTerminal("Prog");
        NonTerminal anything = new NonTerminal("anything");  // temporary hack
        NonTerminal declaration = new NonTerminal("declaration");
        NonTerminal classDecl = new NonTerminal("class decl");
        NonTerminal memberDecl = new NonTerminal("member decl");
        NonTerminal fieldDecl = new NonTerminal("field declaration");
        NonTerminal idType = new NonTerminal("identifier type");
        NonTerminal typeDecl = new NonTerminal("type reference");
        NonTerminal methodDecl = new NonTerminal("method declaration");
        NonTerminal formalParameters = new NonTerminal("formals");
//.........这里部分代码省略.........
开发者ID:Chenguang-Zhu,项目名称:ICE-C5,代码行数:101,代码来源:Grammar.cs


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