// Path: src/main/java/org/apache/jasper/compiler/ELParser.java
// static class TextBuilder extends ELNode.Visitor {
// 
//     protected final boolean isDeferredSyntaxAllowedAsLiteral;
//     protected final StringBuilder output = new StringBuilder();
// 
//     protected TextBuilder(boolean isDeferredSyntaxAllowedAsLiteral) {
//         this.isDeferredSyntaxAllowedAsLiteral = isDeferredSyntaxAllowedAsLiteral;
//     }
// 
//     public String getText() {
//         return output.toString();
//     }
// 
//     @Override
//     public void visit(Root n) throws JasperException {
//         output.append(n.getType());
//         output.append('{');
//         n.getExpression().visit(this);
//         output.append('}');
//     }
// 
//     @Override
//     public void visit(Function n) throws JasperException {
//         output.append(escapeLiteralExpression(n.getOriginalText(), isDeferredSyntaxAllowedAsLiteral));
//         output.append('(');
//     }
// 
//     @Override
//     public void visit(Text n) throws JasperException {
//         output.append(escapeLiteralExpression(n.getText(),isDeferredSyntaxAllowedAsLiteral));
//     }
// 
//     @Override
//     public void visit(ELText n) throws JasperException {
//         output.append(escapeELText(n.getText()));
//     }
// }


import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELManager;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.apache.jasper.JasperException;
import org.apache.jasper.compiler.ELNode.Nodes;
import org.apache.jasper.compiler.ELParser.TextBuilder;
    private void doTestParser(String input, String expectedResult, String expectedBuilderOutput) throws JasperException {

        ELException elException = null;
        String elResult = null;

        // Don't try and evaluate expressions that depend on variables or functions
        if (expectedResult != null) {
            try {
                ELManager manager = new ELManager();
                ELContext context = manager.getELContext();
                ExpressionFactory factory = ELManager.getExpressionFactory();
                ValueExpression ve = factory.createValueExpression(context, input, String.class);
                elResult = ve.getValue(context).toString();
                Assert.assertEquals(expectedResult, elResult);
            } catch (ELException ele) {
                elException = ele;
            }
        }

        Nodes nodes = null;
        try {
            nodes = ELParser.parse(input, false);
            Assert.assertNull(elException);
        } catch (IllegalArgumentException iae) {
            Assert.assertNotNull(elResult, elException);
            // Not strictly true but enables us to report both
            iae.initCause(elException);
            throw iae;
        }

// Path: src/main/java/org/apache/jasper/compiler/ELParser.java
// static class TextBuilder extends ELNode.Visitor {
// 
//     protected final boolean isDeferredSyntaxAllowedAsLiteral;
//     protected final StringBuilder output = new StringBuilder();
// 
//     protected TextBuilder(boolean isDeferredSyntaxAllowedAsLiteral) {
//         this.isDeferredSyntaxAllowedAsLiteral = isDeferredSyntaxAllowedAsLiteral;
//     }
// 
//     public String getText() {
//         return output.toString();
//     }
// 
//     @Override
//     public void visit(Root n) throws JasperException {
//         output.append(n.getType());
//         output.append('{');
//         n.getExpression().visit(this);
//         output.append('}');
//     }
// 
//     @Override
//     public void visit(Function n) throws JasperException {
//         output.append(escapeLiteralExpression(n.getOriginalText(), isDeferredSyntaxAllowedAsLiteral));
//         output.append('(');
//     }
// 
//     @Override
//     public void visit(Text n) throws JasperException {
//         output.append(escapeLiteralExpression(n.getText(),isDeferredSyntaxAllowedAsLiteral));
//     }
// 
//     @Override
//     public void visit(ELText n) throws JasperException {
//         output.append(escapeELText(n.getText()));
//     }
// }


// Path: src/test/java/org/apache/jasper/compiler/TestELParser.java
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELManager;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.apache.jasper.JasperException;
import org.apache.jasper.compiler.ELNode.Nodes;
import org.apache.jasper.compiler.ELParser.TextBuilder;

    private void doTestParser(String input, String expectedResult, String expectedBuilderOutput) throws JasperException {

        ELException elException = null;
        String elResult = null;

        // Don't try and evaluate expressions that depend on variables or functions
        if (expectedResult != null) {
            try {
                ELManager manager = new ELManager();
                ELContext context = manager.getELContext();
                ExpressionFactory factory = ELManager.getExpressionFactory();
                ValueExpression ve = factory.createValueExpression(context, input, String.class);
                elResult = ve.getValue(context).toString();
                Assert.assertEquals(expectedResult, elResult);
            } catch (ELException ele) {
                elException = ele;
            }
        }

        Nodes nodes = null;
        try {
            nodes = ELParser.parse(input, false);
            Assert.assertNull(elException);
        } catch (IllegalArgumentException iae) {
            Assert.assertNotNull(elResult, elException);
            // Not strictly true but enables us to report both
            iae.initCause(elException);
            throw iae;
        }

        TextBuilder textBuilder = new TextBuilder(false);