public void Visit(EscapeSyntax syntax) { var literalSyntax = (LiteralSyntax)syntax.Children[0]; switch (literalSyntax.Token.Character) { case 'd': { int index = GetRandomNumber('0', '9' + 1); LiteralSyntax literal = new LiteralSyntax(new LiteralToken((char)index)); literal.Accept(this); } break; case 'w': { int index = GetRandomNumber(0, WChars.Length); LiteralSyntax literal = new LiteralSyntax(new LiteralToken(WChars[index])); literal.Accept(this); } break; case 's': case 'W': case 'D': throw new NotSupportedException(); default: literalSyntax.Accept(this); break; } }
public void Visit(AnySyntax syntax) { char c = (char)GetRandomNumber(32, 127); LiteralSyntax literal = new LiteralSyntax(new LiteralToken(c)); literal.Accept(this); }
/// <summary> /// Creates the value. /// </summary> public JsonNode CreateValue(LiteralSyntax value, TextRange textRange) { Assume.NotNull(value, nameof(value)); Assume.NotNull(textRange, nameof(textRange)); return(new ValueDeclaration(value, textRange)); }
public void Visit(RangeSyntax syntax) { int min = (int)((LiteralSyntax)syntax.Children[0]).Token.Character; int max = (int)((LiteralSyntax)syntax.Children[1]).Token.Character; int index = GetRandomNumber(min, max + 1); LiteralSyntax literal = new LiteralSyntax(new LiteralToken((char)index)); literal.Accept(this); }
public virtual void VisitLiteral(LiteralSyntax node) { this.Visit(node.NullLiteral); this.Visit(node.BooleanLiteral); this.Visit(node.IntegerLiteral); this.Visit(node.DecimalLiteral); this.Visit(node.ScientificLiteral); this.Visit(node.StringLiteral); }
static Expression BuildLiteral(LiteralSyntax literalSyntax) { switch (literalSyntax.literal) { case Integer integer: return(new Literal { Value = integer.value, ValueType = "Integer", Span = literalSyntax.span }); default: throw new NotImplementedException($"The {literalSyntax.GetType()} is not yet implemented."); } }
private void OutputLiteral(LiteralSyntax node, string prefix) { builder.AddFragment(new OutputFragment(prefix, DefaultColour)); builder.AddFragment(new OutputFragment(node.LiteralToken.ToString(), NumberColour)); }
public void Visit(LiteralSyntax syntax) { builder_.Append((string)syntax.Token.Character.ToString()); }