use of org.antlr.v4.runtime.tree.Tree in project nikita-noark5-core by HiOA-ABI.
the class OdataTest method testOdata.
@RequestMapping(method = RequestMethod.GET, value = "arkivstruktur/{\\w*}")
public ResponseEntity<String> testOdata(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response) throws Exception {
String uqueryString = request.getQueryString();
String decoded = URLDecoder.decode(uqueryString, UTF_8);
StringBuffer originalRequest = request.getRequestURL();
originalRequest.append("?" + decoded);
CharStream stream = CharStreams.fromString(originalRequest.toString());
ODataLexer lexer = new ODataLexer(stream);
CommonTokenStream tokens = new CommonTokenStream(lexer);
ODataParser parser = new ODataParser(tokens);
ParseTree tree = parser.odataURL();
ParseTreeWalker walker = new ParseTreeWalker();
// Make the HQL Statement
NikitaODataToHQLWalker hqlWalker = new NikitaODataToHQLWalker();
walker.walk(hqlWalker, tree);
Session session = entityManager.unwrap(org.hibernate.Session.class);
Query query = hqlWalker.getHqlStatment(session);
String queryString = query.getQueryString();
System.out.println(queryString);
List<NoarkEntity> list = query.getResultList();
return ResponseEntity.status(HttpStatus.CREATED).body(list.toString());
}
use of org.antlr.v4.runtime.tree.Tree in project oxTrust by GluuFederation.
the class ScimFilterParserService method walkTree.
private void walkTree(String filter, ScimFilterBaseListener listener) throws SCIMException {
ScimFilterErrorListener errorListener = new ScimFilterErrorListener();
ParseTree tree = getParseTree(filter, errorListener);
checkParsingErrors(errorListener);
ParseTreeWalker.DEFAULT.walk(listener, tree);
}
use of org.antlr.v4.runtime.tree.Tree in project oxTrust by GluuFederation.
the class ScimFilterParserService method getParseTree.
public ParseTree getParseTree(String filter) throws Exception {
ScimFilterErrorListener errorListener = new ScimFilterErrorListener();
ParseTree tree = getParseTree(filter, errorListener);
checkParsingErrors(errorListener);
return tree;
}
use of org.antlr.v4.runtime.tree.Tree in project grakn by graknlabs.
the class TemplateParser method parseTemplate.
/**
* Parse and resolve a graql template.
* @param templateString a string representing a graql template
* @param data data to use in template
* @return resolved graql query string
*/
public String parseTemplate(String templateString, Map<String, Object> data) {
GraqlErrorListener errorListener = GraqlErrorListener.of(templateString);
CommonTokenStream tokens = lexGraqlTemplate(templateString, errorListener);
ParseTree tree = parseGraqlTemplate(tokens, errorListener);
TemplateVisitor visitor = new TemplateVisitor(tokens, data, macros);
return visitor.visit(tree).toString();
}
use of org.antlr.v4.runtime.tree.Tree in project drools by kiegroup.
the class FEELParserTest method parse.
private BaseNode parse(String input, Map<String, Type> inputTypes) {
FEEL_1_1Parser parser = FEELParser.parse(null, input, inputTypes, Collections.emptyMap(), Collections.emptyList(), Collections.emptyList());
ParseTree tree = parser.expression();
ASTBuilderVisitor v = new ASTBuilderVisitor(inputTypes);
BaseNode expr = v.visit(tree);
return expr;
}
Aggregations