use of org.apache.sling.scripting.sightly.impl.parser.expr.generated.SightlyParser in project sling by apache.
the class ExpressionParser method parseInterpolation.
/**
* Parses the expression string.
*
* @param expressionString as defined by the HTL spec (https://github.com/Adobe-Marketing-Cloud/htl-spec/blob/master/SPECIFICATION.md)
* @return Parsed Expression object
* @throws NullPointerException is the given exprString is null
* @throws SightlyCompilerException if an error occurs while parsing the expression
*/
public Interpolation parseInterpolation(String expressionString) throws SightlyCompilerException {
SightlyParser parser = createParser(expressionString);
try {
Interpolation interpolation = parser.interpolation().interp;
interpolation.setContent(expressionString);
return interpolation;
} catch (RecognitionException e) {
throw new SightlyCompilerException(e);
}
}
use of org.apache.sling.scripting.sightly.impl.parser.expr.generated.SightlyParser in project sling by apache.
the class ExpressionParser method createParser.
private SightlyParser createParser(String string) {
SightlyLexer lexer = new SightlyLexer(new ANTLRInputStream(string));
lexer.removeErrorListeners();
lexer.addErrorListener(new SightlyParserErrorListener());
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
SightlyParser parser = new SightlyParser(tokenStream);
parser.removeErrorListeners();
parser.addErrorListener(new SightlyParserErrorListener());
return parser;
}
Aggregations