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

Literal() public method

public Literal ( Token t ) : LNode
t Token
return LNode
		public LNode Literal(Token t)
		{
			return new StdLiteralNode(t.Value, new SourceRange(_file, t.StartIndex, t.Length), t.Style);
		}

Same methods

LNodeFactory::Literal ( object value, int startIndex = -1, int endIndex = -1 ) : 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));
     }
 }