Beispiel #1
0
        public override List <GeneralError> VisitAdditiveExpr([NotNull] WordLangParser.AdditiveExprContext context)
        {
            var errs = new List <GeneralError>();

            errs.AddRange(Visit(context.multiplicitiveExpr()));
            if (context.additiveExpr() != null)
            {
                errs.AddRange(Visit(context.additiveExpr()));
            }

            return(errs);
        }
Beispiel #2
0
        public override string VisitAdditiveExpr([NotNull] WordLangParser.AdditiveExprContext context)
        {
            var leftText = context.multiplicitiveExpr().GetText();
            var left     = Visit(context.multiplicitiveExpr());

            if (context.additiveExpr() != null)
            {
                var rightText = context.additiveExpr().GetText();
                var right     = Visit(context.additiveExpr());

                var op = Visit(context.additiveOp());

                return($"({op} {left} {right})");
            }
            else
            {
                return($"{left}");
            }
        }