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


C# IdentifierTerminal类代码示例

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


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

示例1: E2Grammar

        public E2Grammar()
        {
            LineTerminators = "\r\n";
            var program = new NonTerminal("Program");
            var directiveList = new NonTerminal("DirectiveList");
            var directive = new NonTerminal("Directive");
            var directiveName = new IdentifierTerminal("DirectiveName");
            var directiveBody = new NonTerminal("DirectiveBody");
            var statementList = new NonTerminal("StatementList");
            var statement = new NonTerminal("Statement");
            var assignment = new NonTerminal("Assignment");
            var expression = new NonTerminal("Expression");
            var parenExpression = new NonTerminal("ParenExpression");
            var methodCall = new NonTerminal("MethodCall");
            var argumentList = new NonTerminal("ArgumentList");
            var argumentTail = new NonTerminal("ArgumentTail");
            var @operator = new NonTerminal("Operator");
            var operation = new NonTerminal("Operation");
            var identifier = new IdentifierTerminal("Identifier");
            var @string = new StringLiteral("String", "\"");
            var number = new NumberLiteral("Number");
            var ifStatement = new NonTerminal("IfStatement");
            var whileStatement = new NonTerminal("WhileStatement");
            var comment = new CommentTerminal("comment", "#", new[] {"\n"});
            var dcom = new CommentTerminal("commentCheat", "@", new[] {"\n"});

            Root = program;

            NonGrammarTerminals.Add(comment);
            NonGrammarTerminals.Add(dcom);

            RegisterBracePair("{", "}");

            program.Rule = /* directiveList + */statementList;

            //directiveList.Rule = MakePlusRule(directiveList, null, directive);
            //directiveBody.Rule = new CommentTerminal()
            //directive.Rule = ToTerm("@") + directiveName + directiveBody;

            statementList.Rule = MakePlusRule(statementList, null, statement);
            statement.Rule = methodCall | assignment;

            expression.Rule = operation | @string | number | methodCall | identifier;

            parenExpression.Rule = ToTerm("(") + expression + ")";

            methodCall.Rule = expression + ":" + identifier + "(" + argumentList + ")";

            argumentList.Rule = MakeStarRule(argumentList, ToTerm(","), expression);

            operation.Rule = expression + @operator + expression;

            @operator.Rule = ToTerm("+") | "-" | "*" | "/" | "&" | "|";

            assignment.Rule = identifier + "=" + expression;

            ifStatement.Rule = ToTerm("if") + parenExpression + "{" + statementList + "}";

            whileStatement.Rule = ToTerm("while") + parenExpression + "{" + statementList + "}";
        }
开发者ID:itsbth,项目名称:E2Edit,代码行数:60,代码来源:E2Grammar.cs

示例2: 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

示例3: ExpressionGrammar

            public ExpressionGrammar()
            {
                var Number = new NumberLiteral("Number");
                var Var = new IdentifierTerminal("Var");
                var conditional_expression = new NonTerminal("conditional_expression");

                //conditional_expression.Rule = expression + PreferShiftHere() + qmark + expression + colon + expression;
                //NonTerminal DataType = new NonTerminal("DataType");

                NonTerminal DecSt = new NonTerminal("DecSt");
                DecSt.Rule = "int" + Var + "=" + Number + ";" | "int" + Var + ";";

                NonTerminal PrintSt = new NonTerminal("PrintSt");
                PrintSt.Rule = "cout <<" + Var;

                //NonTerminal IF = new NonTerminal("IF");
                //IF.Rule = "if( + ;

                NonTerminal stmt = new NonTerminal("stmt");
                stmt.Rule = PrintSt | DecSt;

                NonTerminal stmt1 = new NonTerminal("stmt");
                stmt1.Rule = "begin{" + stmt + "}end;";

                this.Root = DecSt;
            }
开发者ID:khateeb321,项目名称:Compiler-Construction,代码行数:26,代码来源:Form1.cs

示例4: KISGrammer

        public KISGrammer()
        {
            var number = new NumberLiteral("number");
            var text = new StringLiteral("string", "\"");

            number.DefaultIntTypes = new TypeCode[] { TypeCode.Int32, TypeCode.Int64, NumberLiteral.TypeCodeBigInt };
            var identifier = new IdentifierTerminal("identifier");
            var comment = new CommentTerminal("comment", "#", "\n", "\r");
            base.NonGrammarTerminals.Add(comment);

            var Code = new NonTerminal("code");
            var Statments = new NonTerminal("statments");
            var Value = new NonTerminal("value");
            var ValueString = TerminalFactory.CreateCSharpString("valuestring");

            var SetStmt = new NonTerminal("setstmt");
            var CallStmt = new NonTerminal("callstmt");
            var FnStmt = new NonTerminal("fnstmt");

            var CallPath = new NonTerminal("callpath");
            var CallPerams = new NonTerminal("callperams");

            var fullstop = new NonTerminal("fullstop");
            var comma = new NonTerminal("comma");
            var openb = new NonTerminal("openb");
            var closeb = new NonTerminal("closeb");
            openb.Rule = "{";
            closeb.Rule = "}";
            fullstop.Rule = ".";
            comma.Rule = ",";

            CallPath.Rule = MakePlusRule(CallPath, fullstop, identifier);
            CallPerams.Rule = MakePlusRule(CallPerams, comma, Value);

            var Semicolon = ToTerm(";");

            //StateMents:
            SetStmt.Rule = identifier + "=" + Value + Semicolon;
            CallStmt.Rule = (CallPath | identifier) + "(" + (CallPerams | Empty) + ")" + Semicolon;
            FnStmt.Rule = "function" + identifier + "(" + (CallPerams | Empty) + ")";

            Statments.Rule = SetStmt | CallStmt | FnStmt | openb | closeb | Empty;

            var Exspr = new NonTerminal("exspr");
            var Operator = new NonTerminal("operator");
            var ExsprStmt = new NonTerminal("exsprstmt");

            Operator.Rule = ToTerm("/") | "*" | "-" | "+";

            ExsprStmt.Rule = Value + Operator + Value;

            Exspr.Rule = MakePlusRule(Exspr, Operator, ExsprStmt);

            Value.Rule = number | ValueString | identifier | "true" | "false" | Exspr /* | text */;
            Code.Rule = MakePlusRule(Code, NewLine, Statments);
            LanguageFlags = LanguageFlags.NewLineBeforeEOF;
            //code := Statment {statment}
            this.Root = Code;
        }
开发者ID:Myvar,项目名称:PashOS,代码行数:59,代码来源:KISGrammer.cs

示例5: FtpGrammar

        /// <summary>
        /// Class constructor and grammar definition
        /// </summary>
        public FtpGrammar()
            : base(false)
        {
            // declare keywords
            var openKeyword = ToTerm("open");
            var changeDirKeyword = ToTerm("cd");
            var dirKeyword = ToTerm("dir");
            var listKeyword = ToTerm("ls");
            var closeKeyword = ToTerm("close");
            var getKeyword = ToTerm("get");
            var byeKeyword = ToTerm("bye");
            var backfolderKeyword = ToTerm("..");
            var rootfolderKeyword = ToTerm(@"\");

            // declare non-terminals
            var program = new NonTerminal("program");
            var commandList = new NonTerminal("commandList");
            var command = new NonTerminal("command");
            var openCommand = new NonTerminal("open");
            var changeDirCommand = new NonTerminal("cd");
            var dirCommand = new NonTerminal("dir");
            var closeCommand = new NonTerminal("close");
            var getCommand = new NonTerminal("get");
            var byeCommand = new NonTerminal("byeCommand");
            var url = new NonTerminal("url");
            var folderName = new NonTerminal("folderName");

            var quotedUrl = new StringLiteral("quotedUrl", "\"");
            var unquotedUrl = new IdentifierTerminal("unquotedUrl");
            var quotedIdentifier = new StringLiteral("quotedIdentifier", "\"");
            var unquotedIdentifier = new IdentifierTerminal("unquotedIdentifier");
            var filename = new RegexBasedTerminal("filename", @"[a-zA-Z0-9\.\-_]+"); // note: space not allowed.

            // grammar rules
            program.Rule = commandList;
            commandList.Rule = this.MakePlusRule(commandList, null, command);
            command.Rule = openCommand | changeDirCommand | dirCommand | closeCommand | getCommand | byeCommand;

            openCommand.Rule = openKeyword + url + this.NewLine; // string_literal + string_literal +
            changeDirCommand.Rule = changeDirKeyword + rootfolderKeyword + this.NewLine | changeDirKeyword + backfolderKeyword + this.NewLine | changeDirKeyword + folderName + this.NewLine;
            dirCommand.Rule = (dirKeyword | listKeyword) + this.NewLine;
            closeCommand.Rule = closeKeyword + this.NewLine;
            getCommand.Rule = getKeyword + unquotedIdentifier + this.NewLine; // vai ser preciso usar uma regex para o nome do ficheiro
            byeCommand.Rule = byeKeyword + this.NewLine;

            //// string regex = @"^[a-zA-Z0-9\.-_ ]+$" (cuidado com ., .., ...) e os espaços
            //// inválidos: \/:*?"<>|

            url.Rule = quotedUrl | unquotedUrl;
            folderName.Rule = quotedIdentifier | filename;

            // remove these notes as children in the AST
            this.MarkPunctuation("open", "dir", "ls", "close", "get", "cd", "bye");
            this.Root = program;

            // LanguageFlags |= LanguageFlags.CreateAst;
        }
开发者ID:rafathan,项目名称:azureftp-for-sharepoint,代码行数:60,代码来源:FtpGrammar.cs

示例6: SearchGrammar

        public SearchGrammar()
        {
            // Terminals
            var Term = new IdentifierTerminal("Term", "[email protected]#$%^*_'.?", "[email protected]#$%^*_'.?0123456789");
            // The following is not very imporant, but makes scanner recognize "or" and "and" as operators, not Terms
            // The "or" and "and" operator symbols found in grammar get higher priority in scanning and are checked
            // first, before the Term terminal, so Scanner produces operator token, not Term. For our purposes it does
            // not matter, we get around without it.
            Term.Priority = Terminal.LowestPriority;
            var Phrase = new StringLiteral("Phrase");

            // NonTerminals
            var OrExpression = new NonTerminal("OrExpression");
            var OrOperator = new NonTerminal("OrOperator");
            var AndExpression = new NonTerminal("AndExpression");
            var AndOperator = new NonTerminal("AndOperator");
            var ExcludeOperator = new NonTerminal("ExcludeOperator");
            var PrimaryExpression = new NonTerminal("PrimaryExpression");
            var ThesaurusExpression = new NonTerminal("ThesaurusExpression");
            var ThesaurusOperator = new NonTerminal("ThesaurusOperator");
            var ExactOperator = new NonTerminal("ExactOperator");
            var ExactExpression = new NonTerminal("ExactExpression");
            var ParenthesizedExpression = new NonTerminal("ParenthesizedExpression");
            var ProximityExpression = new NonTerminal("ProximityExpression");
            var ProximityList = new NonTerminal("ProximityList");

            this.Root = OrExpression;
            OrExpression.Rule = AndExpression
                              | OrExpression + OrOperator + AndExpression;
            OrOperator.Rule = Symbol("or") | "|";
            AndExpression.Rule = PrimaryExpression
                               | AndExpression + AndOperator + PrimaryExpression;
            AndOperator.Rule = Empty
                             | "and"
                             | "&"
                             | ExcludeOperator;
            ExcludeOperator.Rule = Symbol("-");
            PrimaryExpression.Rule = Term
                                   | ThesaurusExpression
                                   | ExactExpression
                                   | ParenthesizedExpression
                                   | Phrase
                                   | ProximityExpression;
            ThesaurusExpression.Rule = ThesaurusOperator + Term;
            ThesaurusOperator.Rule = Symbol("~");
            ExactExpression.Rule = ExactOperator + Term
                                 | ExactOperator + Phrase;
            ExactOperator.Rule = Symbol("+");
            ParenthesizedExpression.Rule = "(" + OrExpression + ")";
            ProximityExpression.Rule = "<" + ProximityList + ">";

            MakePlusRule(ProximityList, Term);

            RegisterPunctuation("<", ">", "(", ")");
        }
开发者ID:ssuing8825,项目名称:ClientLocate,代码行数:55,代码来源:SearchGrammar.cs

示例7: GrammarEx446

    public GrammarEx446() {
      // A' is augmented root
      NonTerminal S = new NonTerminal("S");
      NonTerminal L = new NonTerminal("L");
      NonTerminal R = new NonTerminal("R");
      Terminal id = new IdentifierTerminal("id");

      S.Rule = L + "=" + R | R;
      L.Rule = "*" + R | id;
      R.Rule = L;
      this.Root = S;
    }//method
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:12,代码来源:GrammarEx446.cs

示例8: ErrorRecoveryGrammar

      public ErrorRecoveryGrammar() {
        var id = new IdentifierTerminal("id");
        var expr = new NonTerminal("expr");
        var stmt = new NonTerminal("stmt");
        var stmtList = new NonTerminal("stmt");

        base.Root = stmtList;
        stmtList.Rule = MakeStarRule(stmtList, stmt);
        stmt.Rule = id + "=" + expr + ";";
        stmt.ErrorRule = SyntaxError + ";";
        expr.Rule = id | id + "+" + id; 
      }
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:12,代码来源:ErrorRecoveryTests.cs

示例9: LinearProgrammingGrammar

        public LinearProgrammingGrammar()
        {
            var comment = new CommentTerminal("comment", "#", "\n", "\r");
            NonGrammarTerminals.Add(comment);

            var identifier = new IdentifierTerminal("appIdentifier");
            var variable = new IdentifierTerminal("variable");

            var number = new NumberLiteral("number", NumberOptions.AllowSign);

            var lpProgram = new NonTerminal("lpApp");
            var lpAppName = new NonTerminal("lpAppName");
            var lpModel = new NonTerminal("lpModel");

            var lpGoal = new NonTerminal("lpGoal");
            var lpPolynomial = new NonTerminal("lpPolynomial");
            var lpConstraints = new NonTerminal("lpConstraints");
            var lpConstraint = new NonTerminal("lpConstraints");
            var lpOperator = new NonTerminal("lpOperator", "lp Operation symbol");
            var lpBinOp = new NonTerminal("lpBinOp", "lp Binary Operation symbol");
            var lpMonomial = new NonTerminal("Monomial");
            var lpNumber = new NonTerminal("lpNumber");

            lpProgram.Rule = lpAppName + "{" + lpModel + "}" + ";";

            lpAppName.Rule = ToTerm("lpmodel") + identifier;

            lpModel.Rule = lpGoal + ToTerm("subject to") +":" + lpConstraints;

            lpGoal.Rule = ToTerm("max") + lpPolynomial | ToTerm("min") + lpPolynomial;

            lpConstraints.Rule = MakePlusRule(lpConstraints, null, lpConstraint);

            //ReduceHere();
            lpConstraint.Rule = lpPolynomial + lpOperator + lpPolynomial + ";";

            lpOperator.Rule = ToTerm("<") | "==" | ">" | "<=" | ">=";

            lpPolynomial.Rule = lpMonomial | lpMonomial + lpBinOp + lpPolynomial  | lpNumber |
                                lpNumber + lpBinOp + lpPolynomial;

            lpMonomial.Rule = variable | lpNumber + ToTerm("*") + variable;

            lpBinOp.Rule = ToTerm("+") | "-";
            lpNumber.Rule = number | lpBinOp + number;

            MarkReservedWords("max", "min", "lpmodel", "subject to");

               // ReduceIf("");
            Root = lpProgram;
        }
开发者ID:taesiri,项目名称:lpSolver,代码行数:51,代码来源:lpGrammar.cs

示例10: Portugol

        public Portugol()
            : base(false)
        {
            LanguageFlags = LanguageFlags.CreateAst;

            var numero = new NumberLiteral("Numero", NumberOptions.AllowSign);
            var identificador = new IdentifierTerminal("Identificador");

            var expressao = new NonTerminal("Expressao", typeof (AstNode));
            var termo = new NonTerminal("Termo", typeof (AstNode));
            var chamadaFuncao = new NonTerminal("Chamada funcao", typeof (ChamadaDeFuncao));
            var operacaoBinaria = new NonTerminal("Operacao binaria", typeof (OperacaoBinaria));
            var operacaoComParentese = new NonTerminal("Operacao com parentese", typeof (AstNode));
            var se = new NonTerminal("Se", typeof (CondicaoSe));
            var operador = new NonTerminal("Operador", typeof(AstNode));
            var operadorLogico = new NonTerminal("Operador logico", typeof (AstNode));
            var argumentos = new NonTerminal("Argumentos", typeof (AstNode));
            var sePart = new NonTerminal("Se parte", typeof (AstNode));
            var entaoPart = new NonTerminal("Entao parte", typeof (AstNode));
            var senaoPart = new NonTerminal("Senao parte", typeof (AstNode));

            NonGrammarTerminals.Add(new CommentTerminal("comment1", "/*", "*/"));

            expressao.Rule = operacaoBinaria | operacaoComParentese | se | chamadaFuncao | termo;
            termo.Rule = numero;
            operacaoComParentese.Rule = ToTerm("(") + expressao + ")";
            operacaoBinaria.Rule = expressao + operador + expressao;
            operador.Rule = ToTerm("+") | "-" | "*" | "/" | "^" | "%" | "=" | "<" | ">" | "<=" | ">=" | "<>" | "E" | "OU";

            sePart.Rule = ToTerm("Se");
            entaoPart.Rule = ToTerm("Entao");
            senaoPart.Rule = ToTerm("Senao");

            se.Rule = sePart + expressao + entaoPart + expressao + senaoPart + expressao;

            argumentos.Rule = MakePlusRule(argumentos, ToTerm(","), expressao);

            chamadaFuncao.Rule = identificador | identificador + "(" + argumentos + ")";

            RegisterOperators(1, "E", "OU");
            RegisterOperators(5, "=", "<", ">", "<=", ">=", "<>");
            RegisterOperators(10, "+", "-");
            RegisterOperators(20, "*", "/", "%", "^");
            MarkPunctuation("(", ")");
            RegisterBracePair("(", ")");

            MarkTransient(expressao, operador, termo, operadorLogico, operacaoComParentese);
            Root = expressao;
            LanguageFlags = LanguageFlags.CreateAst;
        }
开发者ID:AlbertoMonteiro,项目名称:Portugol-with-CSharp,代码行数:50,代码来源:Portugol.cs

示例11: ExpressionEvaluatorGrammar

        public ExpressionEvaluatorGrammar()
        {
            // 1. Terminals
              var number = new NumberLiteral("number");
              var identifier = new IdentifierTerminal("identifier");
              var comment = new CommentTerminal("comment", "#", "\n", "\r");
              base.NonGrammarTerminals.Add(comment);

              // 2. Non-terminals
              var Variable = new NonTerminal("Variable", typeof(VarRefNode));
              var Expr = new NonTerminal("Expr");
              var Term = new NonTerminal("Term");
              var BinExpr = new NonTerminal("BinExpr", typeof(BinExprNode));
              var ParExpr = new NonTerminal("ParExpr");
              var UnExpr = new NonTerminal("UnExpr", typeof(UnExprNode));
              var UnOp = new NonTerminal("UnOp");
              var BinOp = new NonTerminal("BinOp");
              var AssignmentStmt = new NonTerminal("AssignmentStmt", typeof(AssigmentNode));
              var Statement = new NonTerminal("Statement");
              var ProgramLine = new NonTerminal("ProgramLine");
              var Program = new NonTerminal("Program", typeof(StatementListNode));

              // 3. BNF rules
              Variable.Rule = identifier;
              Expr.Rule = Term | UnExpr | BinExpr;
              Term.Rule = number | ParExpr | Variable;
              ParExpr.Rule = "(" + Expr + ")";
              UnExpr.Rule = UnOp + Term;
              UnOp.Rule = Symbol("+") | "-";
              BinExpr.Rule =  Expr + BinOp + Expr;
              BinOp.Rule = Symbol("+") | "-" | "*" | "/" | "**";
              AssignmentStmt.Rule = Variable + "=" + Expr;
              Statement.Rule = AssignmentStmt | Expr | Empty;
              ProgramLine.Rule = Statement + NewLine;
              Program.Rule = MakeStarRule(Program, ProgramLine);
              this.Root = Program;       // Set grammar root

              // 4. Operators precedence
              RegisterOperators(1, "+", "-");
              RegisterOperators(2, "*", "/");
              RegisterOperators(3, Associativity.Right, "**");

              RegisterPunctuation( "(", ")");
              MarkTransient(Term, Expr, Statement);

              //automatically add NewLine before EOF so that our BNF rules work correctly when there's no final line break in source
              this.LanguageFlags |= LanguageFlags.NewLineBeforeEOF | LanguageFlags.SupportsInterpreter;
        }
开发者ID:TheByte,项目名称:sones,代码行数:48,代码来源:ExpressionEvaluatorGrammar.cs

示例12: NumericalSchemeGrammar

        public NumericalSchemeGrammar()
        {
            this.GrammarComments = "";

            //Symbols
            var whitespace = new NonTerminal("WhiteSpace", Empty | " " | "\t");
            // Comments
            var singleLineComment = new CommentTerminal("SingleLineComment", "//", "\r", "\n", "\u2085", "\u2028", "\u2029");
            var multiLineComment = new CommentTerminal("DelimitedComment", "/*", "*/");
            NonGrammarTerminals.Add(singleLineComment);
            NonGrammarTerminals.Add(multiLineComment);

            //Terminals
            var semicolon = ToTerm(";", "Semicolon");
            var ofString = new StringLiteral("String", "\"");
            var ofNumber = new NumberLiteral("Number", NumberOptions.AllowSign);
            var ofIdentifier = TerminalFactory.CreateCSharpIdentifier("Identifier");
            var ofArrayTerm = new IdentifierTerminal("SchemeTerm", "(),|*.+-/%^~!&");

            //Non-terminals
            var ofValue = new NonTerminal("Value");

            var ofDictionary = new NonTerminal("Dictionary");
            var ofDictionaryContent = new NonTerminal("DictionaryContent");
            var ofDictionaryContentWrapper = new NonTerminal("DictionaryContentWrapper");
            var ofDictEntry = new NonTerminal("DictEntry");

            var ofArrayEntry = new NonTerminal("ArrayEntry");
            var ofArray = new NonTerminal("Array");
            var ofArrayWrapper = new NonTerminal("ArrayWrapper");

            //BNF
            ofValue.Rule = ofIdentifier | ofArrayTerm | ofString | ofNumber;

            ofDictEntry.Rule = ofArrayWrapper | ofDictionary;
            ofDictionaryContent.Rule = MakeStarRule(ofDictionaryContent, whitespace, ofDictEntry);
            ofDictionaryContentWrapper.Rule = "{" + ofDictionaryContent + "}";
            ofDictionary.Rule = ofIdentifier + whitespace + ofDictionaryContentWrapper;

            ofArrayEntry.Rule = ofValue;
            ofArray.Rule = MakeStarRule(ofArray, whitespace, ofArrayEntry);
            ofArrayWrapper.Rule = ofArray + semicolon;

            //Set grammar root
            this.Root = ofDictionaryContent;
            MarkPunctuation("{", "}");
            MarkTransient(ofValue, ofDictionaryContentWrapper);
        }
开发者ID:mohsenboojari,项目名称:offwind,代码行数:48,代码来源:NumericalSchemeGrammar.cs

示例13: Kbtter3QueryGrammar

        /// <summary>
        /// 使うな
        /// </summary>
        public Kbtter3QueryGrammar()
            : base()
        {
            //コメント
            var comment = new CommentTerminal("Comment", "/*", "*/");
            NonGrammarTerminals.Add(comment);

            //リテラル
            var number = new NumberLiteral("Number", NumberOptions.AllowSign | NumberOptions.AllowStartEndDot);
            var str = new StringLiteral("String", "\"");
            var regex = new RegexLiteral("Regex", '/', '\\');
            var ident = new IdentifierTerminal("Identifer");

            //非終端
            var Value = new NonTerminal("Value");
            var Term = new NonTerminal("Term");
            var Expression = new NonTerminal("Expression");
            var BinExpression = new NonTerminal("BinExpression");
            var ParExpression = new NonTerminal("ParExpression");
            var PostfixExpression = new NonTerminal("PostfixExpression");
            var Operator = new NonTerminal("Operator");

            //非終端定義
            Value.Rule = number | str | ident | regex | "null" | "true" | "false";
            Term.Rule = Value | ParExpression;
            Operator.Rule = ToTerm("==") | "!=" | ">" | "<" | ">=" | "<=" | "match" | "&&" | "||" | "+" | "-" | "*" | "/" | "%" | "&" | "|" | "^" | ".";
            BinExpression.Rule = Expression + Operator + Expression;
            PostfixExpression.Rule = (ToTerm("+") + Term) | ("-" + Term) | ("!" + Term);
            Expression.Rule = BinExpression | Term | PostfixExpression;
            ParExpression.Rule = ToTerm("(") + Expression + ")";

            RegisterOperators(10, ".");
            RegisterOperators(9, "*", "/", "%");
            RegisterOperators(8, "+", "-");
            RegisterOperators(7, ">", "<", ">=", "<=", "match");
            RegisterOperators(6, "==", "!=");
            RegisterOperators(5, "&");
            RegisterOperators(4, "^");
            RegisterOperators(3, "|");
            RegisterOperators(2, "&&");
            RegisterOperators(1, "||");

            Root = Expression;
            MarkPunctuation("(", ")");
            MarkTransient(Expression, ParExpression, Value, Operator, Term);
        }
开发者ID:kb10uy,项目名称:Kbtter4,代码行数:49,代码来源:Kbtter3QueryGrammar.cs

示例14: ConflictGrammarWithHintsInRules

    public ConflictGrammarWithHintsInRules()  : base(true) {
      var name = new IdentifierTerminal("id");

      var definition = new NonTerminal("definition");
      var fieldDef = new NonTerminal("fieldDef");
      var propDef = new NonTerminal("propDef");
      var fieldModifier = new NonTerminal("fieldModifier");
      var propModifier = new NonTerminal("propModifier");

      definition.Rule = fieldDef | propDef;
      fieldDef.Rule = fieldModifier + name + name + ";";
      propDef.Rule = propModifier + name + name + "{" + "}";
      var fieldHint = ReduceIf(";", comesBefore: "{");
      fieldModifier.Rule = "public" + fieldHint | "private" + fieldHint | "readonly";
      propModifier.Rule = ToTerm("public") | "private" | "override";

      Root = definition;
    }
开发者ID:androdev4u,项目名称:XLParser,代码行数:18,代码来源:ConflictGrammars.cs

示例15: ExpressionGrammar

        public ExpressionGrammar()
        {
            this.GrammarComments = @"Arithmetical expressions for dynamic geometry.";

            // 1. Terminals
            var number = new NumberLiteral("number");
            var identifier = new IdentifierTerminal("identifier");

            // 2. Non-terminals
            var Expr = new NonTerminal("Expr");
            var Term = new NonTerminal("Term");
            var BinExpr = new NonTerminal("BinExpr");
            var ParExpr = new NonTerminal("ParExpr");
            var UnExpr = new NonTerminal("UnExpr");
            var UnOp = new NonTerminal("UnOp");
            var BinOp = new NonTerminal("BinOp", "operator");
            var PropertyAccess = new NonTerminal("PropertyAccess");
            var FunctionCall = new NonTerminal("FunctionCall");
            var CommaSeparatedIdentifierList = new NonTerminal("PointArgumentList");
            var ArgumentList = new NonTerminal("ArgumentList");

            // 3. BNF rules
            Expr.Rule = Term | UnExpr | BinExpr;
            Term.Rule = number | identifier | ParExpr | FunctionCall | PropertyAccess;
            UnExpr.Rule = UnOp + Term;
            UnOp.Rule = ToTerm("-");
            BinExpr.Rule = Expr + BinOp + Expr;
            BinOp.Rule = ToTerm("+") | "-" | "*" | "/" | "^";
            PropertyAccess.Rule = identifier + "." + identifier;
            FunctionCall.Rule = identifier + "(" + ArgumentList + ")";
            ArgumentList.Rule = Expr | CommaSeparatedIdentifierList;
            ParExpr.Rule = "(" + Expr + ")";
            CommaSeparatedIdentifierList.Rule = MakePlusRule(CommaSeparatedIdentifierList, ToTerm(","), identifier);

            this.Root = Expr;

            // 4. Operators precedence
            RegisterOperators(1, "+", "-");
            RegisterOperators(2, "*", "/");
            RegisterOperators(3, Associativity.Right, "^");

            MarkPunctuation("(", ")", ".", ",");
            MarkTransient(Term, Expr, BinOp, UnOp, ParExpr, ArgumentList, CommaSeparatedIdentifierList);
        }
开发者ID:ondrej11,项目名称:o106,代码行数:44,代码来源:Grammar.cs


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