public void TokenHandleReturnsEmptyStringOnceItIsRunOut() { var th = new TokenizerHandle("hello" + Environment.NewLine + "world"); th.Advance(); th.CurrentLine.ShouldBeEqualTo("hello"); th.CurrentHandled(); th.Advance(); th.CurrentLine.ShouldBeEqualTo("world"); th.CurrentHandled(); th.Advance(); th.CurrentLine.ShouldBeNull(); }
protected void extractScript(TokenizerHandle h) { h.CurrentHandled(); h.Advance(); var rEnd = new Regex(@"\s*" + Terminator); var b = new StringBuilder(); while (!rEnd.IsMatch(h.CurrentLine)) { b.AppendLine(h.CurrentLine); h.CurrentHandled(); h.Advance(); } Script = b.ToString(); }
protected override AbstractToken handle(TokenizerHandle handle) { if (!commentMatch.IsMatch(handle.CurrentLine)) return null; handle.CurrentHandled(); return this; }
protected override AbstractToken handle(TokenizerHandle handle) { var match = psScriptStart.Match(handle.CurrentLine); if (match.Groups.Count != 2) return null; Terminator = match.Groups[1].Value; extractScript(handle); handle.CurrentHandled(); return this; }
protected override AbstractToken handle(TokenizerHandle handle) { var match = matchBacktick.Match(handle.CurrentLine); if (match.Groups.Count > 1) { BackTickValue = match.Groups[1].Value; handle.CurrentHandled(); return this; } return null; }
protected override AbstractToken handle(TokenizerHandle tHandle) { var m = matchRegEx.Match(tHandle.CurrentLine); if (m.Groups.Count == 0 || m.Groups.Count != 3) return null; VariableName = m.Groups[1].Captures[0].Value.Trim(' '); Value = m.Groups[2].Captures[0].Value.Trim(' '); tHandle.CurrentHandled(); withinHandle(tHandle); return this; }