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


C# StringLiteral类代码示例

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


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

示例1: ParseExpr

    private Expr ParseExpr()
    {
        if (this.index == this.tokens.Count)
        {
            throw new System.Exception("expected expression, got EOF");
        }

        if (this.tokens[this.index] is Text.StringBuilder)
        {
            string value = ((Text.StringBuilder)this.tokens[this.index++]).ToString();
            StringLiteral stringLiteral = new StringLiteral();
            stringLiteral.Value = value;
            return stringLiteral;
        }
        else if (this.tokens[this.index] is int)
        {
            int intValue = (int)this.tokens[this.index++];
            IntLiteral intLiteral = new IntLiteral();
            intLiteral.Value = intValue;
            return intLiteral;
        }
        else if (this.tokens[this.index] is string)
        {
            string ident = (string)this.tokens[this.index++];
            Variable var = new Variable();
            var.Ident = ident;
            return var;
        }
        else
        {
            throw new System.Exception("expected string literal, int literal, or variable");
        }
    }
开发者ID:santosh-mnrec,项目名称:Compiler,代码行数:33,代码来源:Parser.cs

示例2: PredicateLike

		protected PredicateLike(Expression valueExpression, bool not, Expression pattern, StringLiteral escape): base(not) {
			Debug.Assert(valueExpression != null);
			Debug.Assert(pattern != null);
			this.valueExpression = valueExpression;
			this.pattern = pattern;
			this.escape = escape;
		}
开发者ID:avonwyss,项目名称:bsn-modulestore,代码行数:7,代码来源:PredicateLike.cs

示例3: CreateVbString

 public static StringLiteral CreateVbString(string name) {
   StringLiteral term = new StringLiteral(name);
   term.AddStartEnd("\"", StringOptions.NoEscapes | StringOptions.AllowsDoubledQuote);
   term.AddSuffix("$", TypeCode.String);
   term.AddSuffix("c", TypeCode.Char);
   return term;
 }
开发者ID:anukat2015,项目名称:sones,代码行数:7,代码来源:TerminalFactory.cs

示例4: CreateZodiacString

 public static StringLiteral CreateZodiacString(string name)
 {
     StringLiteral term = new StringLiteral(name);
     //term.AddStartEnd("'", StringOptions.AllowsAllEscapes);// AllowLineBreak??
     term.AddStartEnd("\"", StringOptions.AllowsAllEscapes);// AllowLineBreak??
     return term;
 }
开发者ID:zackszhu,项目名称:ZodiacLanguage,代码行数:7,代码来源:ZodiacTerminalFactory.cs

示例5: CreateStringLiteral

 private StringLiteral CreateStringLiteral(string name)
 {
     var term = new StringLiteral(name);
     term.AddStartEnd("\"", StringOptions.AllowsAllEscapes);
     term.AddStartEnd("'", StringOptions.AllowsDoubledQuote | StringOptions.AllowsOctalEscapes | StringOptions.AllowsUEscapes | StringOptions.AllowsXEscapes);
     return term;
 }
开发者ID:Karapuska,项目名称:Totem,代码行数:7,代码来源:TotemGrammar.Literals.cs

示例6: JsonGrammar

    public JsonGrammar() {
      //Terminals
      var jstring = new StringLiteral("string", "\"");
      var jnumber = new NumberLiteral("number");
      var comma = ToTerm(","); 
      
      //Nonterminals
      var jobject = new NonTerminal("Object"); 
      var jobjectBr = new NonTerminal("ObjectBr");
      var jarray = new NonTerminal("Array"); 
      var jarrayBr = new NonTerminal("ArrayBr");
      var jvalue = new NonTerminal("Value");
      var jprop = new NonTerminal("Property"); 

      //Rules
      jvalue.Rule = jstring | jnumber | jobjectBr | jarrayBr | "true" | "false" | "null";
      jobjectBr.Rule = "{" + jobject + "}";
      jobject.Rule = MakeStarRule(jobject, comma, jprop);
      jprop.Rule = jstring + ":" + jvalue;
      jarrayBr.Rule = "[" + jarray + "]";
      jarray.Rule = MakeStarRule(jarray, comma, jvalue);

      //Set grammar root
      this.Root = jvalue;
      MarkPunctuation("{", "}", "[", "]", ":", ",");
      this.MarkTransient(jvalue, jarrayBr, jobjectBr);

    }//constructor
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:28,代码来源:JsonGrammar.cs

示例7: OpenxmlColumn

		public OpenxmlColumn(ColumnName columnName, TypeName columnType, StringLiteral columnPattern) {
			Debug.Assert(columnName != null);
			Debug.Assert(columnType != null);
			this.columnName = columnName;
			this.columnType = columnType;
			this.columnPattern = columnPattern;
		}
开发者ID:avonwyss,项目名称:bsn-modulestore,代码行数:7,代码来源:OpenxmlColumn.cs

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

示例9: CreateCSharpString

 public static StringLiteral CreateCSharpString(string name)
 {
     var term = new StringLiteral(name, "\"", StringOptions.AllowsAllEscapes);
     term.AddPrefix("@",
         StringOptions.NoEscapes | StringOptions.AllowsLineBreak | StringOptions.AllowsDoubledQuote);
     return term;
 }
开发者ID:HyperSharp,项目名称:Hyperspace.DotLua,代码行数:7,代码来源:TerminalFactory.cs

示例10: JsonGrammar

        public JsonGrammar()
        {
            //Terminals
              var jstring = new StringLiteral("string", "\"");
              var jnumber = new NumberLiteral("number");
              var comma = Symbol(",");

              //Nonterminals
              var jobject = new NonTerminal("Object");
              var jarray = new NonTerminal("Array");
              var jvalue = new NonTerminal("Value");
              var jprop = new NonTerminal("Property");
              var jproplist = new NonTerminal("PropertyList");
              var jlist = new NonTerminal("List");

              //Rules
              jvalue.Rule = jstring | jnumber | jobject | jarray | "true" | "false" | "null";
              jobject.Rule = "{" + jproplist + "}";
              jproplist.Rule = MakeStarRule(jproplist, comma, jprop);
              jprop.Rule = jstring + ":" + jvalue;
              jarray.Rule = "[" + jlist + "]";
              jlist.Rule = MakeStarRule(jlist, comma, jvalue);

              //Set grammar root
              this.Root = jvalue;
              RegisterPunctuation("{", "}", "[", "]", ":", ",");
              this.MarkTransient(jvalue, jlist, jproplist);
              this.LanguageFlags = LanguageFlags.None; //.BubbleNodes;
        }
开发者ID:TheByte,项目名称:sones,代码行数:29,代码来源:JsonGrammar.cs

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

示例12: IntegrationTestGrammar

 public IntegrationTestGrammar() {
   var comment = new CommentTerminal("comment", "/*", "*/");
   base.NonGrammarTerminals.Add(comment);
   var str = new StringLiteral("str", "'", StringOptions.AllowsLineBreak);
   var stmt = new NonTerminal("stmt");
   stmt.Rule = str | Empty;
   this.Root = stmt; 
 }
开发者ID:gregberns,项目名称:Irony,代码行数:8,代码来源:IntegrationTests.cs

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

示例14: SearchGrammar

        public SearchGrammar()
            : base(false)
        {
            this.GrammarComments =
            "Google-to-SQL full-text query format converter. Based on original project by Michael Coles.\r\n" +
            "http://www.sqlservercentral.com/articles/Full-Text+Search+(2008)/64248/ \r\n" +
            "Slightly revised to work with latest version of Irony. ";

              // Terminals
              var Term = CreateTerm("Term");
              var Phrase = new StringLiteral("Phrase", "\"");
              var ImpliedAnd = new ImpliedSymbolTerminal("ImpliedAnd");

              // NonTerminals
              var BinaryExpression = new NonTerminal("BinaryExpression");
              var BinaryOp = new NonTerminal("BinaryOp");
              var Expression = new NonTerminal("Expression");
              var PrimaryExpression = new NonTerminal("PrimaryExpression");
              var ThesaurusExpression = new NonTerminal("ThesaurusExpression");
              var ThesaurusOperator = new NonTerminal("ThesaurusOperator");
              var ExactExpression = new NonTerminal("ExactExpression");
              var ParenthesizedExpression = new NonTerminal("ParenthesizedExpression");
              var ProximityExpression = new NonTerminal("ProximityExpression");
              var ProximityList = new NonTerminal("ProximityList");

              this.Root = Expression;
              Expression.Rule = PrimaryExpression | BinaryExpression;
              BinaryExpression.Rule = Expression + BinaryOp + Expression;
              BinaryOp.Rule = ImpliedAnd | "and" | "&" | "-" | "or" | "|";
              PrimaryExpression.Rule = Term
                                 | ThesaurusExpression
                                 | ExactExpression
                                 | ParenthesizedExpression
                                 | Phrase
                                 | ProximityExpression;
              ThesaurusExpression.Rule = "~" + Term;
              ExactExpression.Rule = "+" + Term | "+" + Phrase;
              ParenthesizedExpression.Rule = "(" + Expression + ")";
              ProximityExpression.Rule = "<" + ProximityList + ">";
              MakePlusRule(ProximityList, Term);

              MarkTransient(PrimaryExpression, Expression, ProximityExpression, ParenthesizedExpression, BinaryOp);
              MarkPunctuation("<", ">", "(", ")");
              RegisterOperators(10, "or", "|");
              RegisterOperators(20, "and", "&", "-");
              RegisterOperators(20, ImpliedAnd);
              //Register brace pairs to improve error reporting
              RegisterBracePair("(", ")");
              RegisterBracePair("<", ">");
              //Do not report ImpliedAnd as expected symbol - it is not really a symbol
              this.AddToNoReportGroup(ImpliedAnd);
              //also do not report braces as expected
              this.AddToNoReportGroup("(", ")", "<", ">");

              LanguageFlags |= LanguageFlags.CanRunSample;
        }
开发者ID:cubean,项目名称:CG,代码行数:56,代码来源:SearchGrammar.cs

示例15: AllowStringEqualityAndInequalityComparison

        public void AllowStringEqualityAndInequalityComparison(string op)
        {
            var left = new StringLiteral ("foobar");
            var right = new StringLiteral ("baz");
            var compared = new BinaryOperation (op, left, right);

            var type = compared.Walk (new TypeChecker ());

            Assert.AreEqual (SpecType.Boolean, type.Type);
        }
开发者ID:couchand,项目名称:oracular-dot-net,代码行数:10,代码来源:TypeCheckerTests.cs


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