All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.avaje.ebeaninternal.server.grammer.EqlParser Maven / Gradle / Ivy

There is a newer version: 8.1.1
Show newest version
package com.avaje.ebeaninternal.server.grammer;

import com.avaje.ebeaninternal.api.SpiQuery;
import com.avaje.ebeaninternal.server.grammer.antlr.EQLLexer;
import com.avaje.ebeaninternal.server.grammer.antlr.EQLParser;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTreeWalker;

/**
 * Parse EQL query language applying it to an ORM query object.
 */
public class EqlParser {

  /**
   * Parse the raw EQL query and apply it to the supplied query.
   */
  public static  void parse(String raw, SpiQuery query) {

    EQLLexer lexer = new EQLLexer(new ANTLRInputStream(raw));
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    EQLParser parser = new EQLParser(tokens);
    EQLParser.Select_statementContext context = parser.select_statement();

    EqlAdapter adapter = new EqlAdapter(query);

    ParseTreeWalker walker = new ParseTreeWalker();
    walker.walk(adapter, context);

    query.simplifyExpressions();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy