Loyc.Syntax.LNodeFactory.Literal C# (CSharp) Method

Literal() public method

public Literal ( object value, int startIndex = -1, int endIndex = -1 ) : LNode
value object
startIndex int
endIndex int
return LNode
		public LNode Literal(object value, int startIndex = -1, int endIndex = -1)
		{
			if (endIndex < startIndex) endIndex = startIndex;
			return new StdLiteralNode(value, new SourceRange(_file, startIndex, endIndex - startIndex));
		}
		public LNode Literal(Token t)

Same methods

LNodeFactory::Literal ( Token t ) : LNode

Usage Example

Example #1
0
 private LNode GenerateRandomNode(LNodeFactory Factory, Random Rand, int Depth)
 {
     int index = Rand.Next(5);
     switch (Depth <= 0 && index > 1 ? Rand.Next(2) : index)
     {
         case 0:
             return Factory.Literal(GenerateRandomLiteral(Rand));
         case 1:
             return Factory.Id(GenerateRandomSymbol(Rand));
         case 2:
             return Factory.Attr(GenerateRandomNode(Factory, Rand, Depth - 1), GenerateRandomNode(Factory, Rand, Depth - 1));
         case 3:
             return Factory.Call(GenerateRandomSymbol(Rand), GenerateRandomNodeList(Factory, Rand, Depth - 1));
         default:
             return Factory.Call(GenerateRandomNode(Factory, Rand, Depth - 1), GenerateRandomNodeList(Factory, Rand, Depth - 1));
     }
 }