public void WildExtract(string script, int position, string expectedtype, string expectedresult, string expectedfullresult) { IScriptToken token = extractor.ExtractToken(script, position, false); if (string.IsNullOrEmpty(expectedtype)) { Assert.Null(token); return; } Assert.NotNull(token); Console.WriteLine(token.ToString()); Assert.AreEqual(expectedtype, token.GetType().Name); Assert.AreEqual(expectedresult, token.ToString()); token = extractor.ExtractToken(script, position); Assert.NotNull(token); Console.WriteLine(token.ToString()); Assert.AreEqual(expectedtype, token.GetType().Name); Assert.AreEqual(expectedfullresult, token.ToString()); }
/// <inheritdoc /> public ITokenFormatter this[IScriptToken token] { get { if (token == null) { throw new ArgumentNullException(nameof(token)); } Type tokentype = token.GetType(); if (formatters.TryGetValue(tokentype, out ITokenFormatter result)) { return(result); } PrepareHandler(tokentype); return(formatters[tokentype]); } }
public void AddChild(IScriptToken child) { if (child is Case @case) { if (@case.IsDefault) { Default = @case; } else { AddCase(@case); } } else if (!(child is Comment || child is NewLine)) { throw new ScriptParserException(TextIndex, -1, LineNumber, $"Switch body can not contain {child.GetType().Name}"); } body.Add(child); }