public override ISexpr VisitAtom(SexprParser.AtomContext context) { var text = context.GetText(); if (context.SYMBOL() != null) { return(Sexpr.Symbol(text)); } else if (context.STRING() != null) { return(Sexpr.String(text)); } else if (context.NUMBER() != null) { return(Sexpr.Number(text)); } else { throw new Exception(); } }
public override ISexpr VisitQuote(SexprParser.QuoteContext context) { return(Sexpr.List(new[] { Sexpr.Symbol("quote"), VisitItem(context.item()) })); }
public override ISexpr VisitList(SexprParser.ListContext context) { return(Sexpr.List(context.item() .Select(VisitItem))); }
public override ISexpr VisitPair(SexprParser.PairContext context) { return(Sexpr.Pair( VisitItem(context.item(0)), VisitItem(context.item(1)))); }