Package org.antlr.v4.runtime

Examples of org.antlr.v4.runtime.CharStream


    String sql = cmd.getArgs().length > 0 ? cmd.getArgs()[0] : STATEMENT;

    ObjectMapper objectMapper = new DefaultObjectMapper();
    ObjectWriter jsonWriter = objectMapper.writerWithDefaultPrettyPrinter();

    CharStream stream = new ANTLRInputStream(sql);
    DruidSQLLexer lexer = new DruidSQLLexer(stream);
    TokenStream tokenStream = new CommonTokenStream(lexer);
    DruidSQLParser parser = new DruidSQLParser(tokenStream);
    lexer.removeErrorListeners();
    parser.removeErrorListeners();
View Full Code Here


public class Main {
 

    public static void main(String[] args) throws Exception {
        //String input = "hi";
        CharStream mstream = new ANTLRFileStream("c:\\android\\test.txt");

        MAG1Lexer lexer = new MAG1Lexer(mstream);
        TokenStream mstreaStream = new CommonTokenStream(lexer);
        MAG1Parser parser = new MAG1Parser(mstreaStream);
        //parser.getTrimParseTree();
View Full Code Here

    protected static String lexSampleSQL(String querySQL)
                throws ExprValidationException
    {
        querySQL = querySQL.replaceAll("\\s\\s+|\\n|\\r", " ");
        StringReader reader = new StringReader(querySQL);
        CharStream input;
        try
        {
            input = new NoCaseSensitiveStream(reader);
        }
        catch (IOException ex)
View Full Code Here

        }
        return undeployedTypes;
    }

    public static ParseNode getModule(EPLModuleParseItem item, String resourceName) throws ParseException, IOException {
        CharStream input = new NoCaseSensitiveStream(new StringReader(item.getExpression()));

        EsperEPL2GrammarLexer lex = ParseHelper.newLexer(input);
        CommonTokenStream tokenStream = new CommonTokenStream(lex);
        tokenStream.fill();
View Full Code Here

        return new ParseException(message);
    }

    public static List<EPLModuleParseItem> parse(String module) {

        CharStream input;
        try
        {
            input = new NoCaseSensitiveStream(new StringReader(module));
        }
        catch (IOException ex)
View Full Code Here

     * @param propertyName to parse
     * @return AST syntax tree
     */
    public static EsperEPL2GrammarParser.StartEventPropertyRuleContext parse(String propertyName)
    {
        CharStream input;
        try {
            input = new NoCaseSensitiveStream(new StringReader(propertyName));
        }
        catch (IOException ex) {
            throw new PropertyAccessException("IOException parsing property name '" + propertyName + '\'', ex);
View Full Code Here

    private static EsperEPL2GrammarParser.StartEventPropertyRuleContext handleRecognitionEx(RecognitionException e, CommonTokenStream tokens, String propertyName, EsperEPL2GrammarParser g) {
        // Check for keywords and escape each, parse again
        String escapedPropertyName = escapeKeywords(tokens);

        CharStream inputEscaped;
        try {
            inputEscaped = new NoCaseSensitiveStream(new StringReader(escapedPropertyName));
        }
        catch (IOException ex) {
            throw new PropertyAccessException("IOException parsing property name '" + propertyName + '\'', ex);
View Full Code Here

   *
   * @param input
   *            The input string to parse.
   */
  private void parse(String input) {
    CharStream charStream = new ANTLRInputStream(input);
    jcfLexer lexer = new jcfLexer(charStream);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    jcfParser parser = new jcfParser(tokens);
    parser.setErrorHandler(new ExceptionErrorStrategy());
    parser.query();
View Full Code Here

*/
public class ANTLR4Parser extends AbstractParser {

  @Override
  protected AbstractExpression doParse(String query) throws ParsingException {
    CharStream charStream = new ANTLRInputStream(query);
    jcfLexer lexer = new jcfLexer(charStream);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    jcfParser parser = new jcfParser(tokens);
    parser.setErrorHandler(new ExceptionErrorStrategy());
    parser.query();
View Full Code Here

    setup(cu);
    registry.clearForType(JavaCompletionTypes.CUSTOM_TYPE);
    registry.clearForType(JavaCompletionTypes.FIELD);
    registry.clearForType(JavaCompletionTypes.NAME);
    Lexer lexer = new JavaLexer(new ANTLRInputStream(txt));
    CommonTokenStream tokens = new CommonTokenStream(lexer);

    // Create a parser that reads from the scanner
    JavaParser parser = new JavaParser(tokens);
    parser.removeErrorListeners();
   
View Full Code Here

TOP

Related Classes of org.antlr.v4.runtime.CharStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.