public void TestLine() { SpeakParser parser = Setup("john says \"hello\" \n"); SpeakParser.LineContext context = parser.line(); SpeakVisitor visitor = new SpeakVisitor(); SpeakLine line = (SpeakLine)visitor.VisitLine(context); Assert.AreEqual("john", line.Person); Assert.AreEqual("hello", line.Text); }
public override object VisitLine(SpeakParser.LineContext context) { NameContext name = context.name(); OpinionContext opinion = context.opinion(); SpeakLine line = new SpeakLine() { Person = name.GetText(), Text = opinion.GetText().Trim('"') }; Lines.Add(line); return(line); }