Package org.antlr.runtime

Examples of org.antlr.runtime.ANTLRInputStream


        }
    }

    public static DRLLexer buildLexer( final InputStream is, final String encoding, LanguageLevelOption languageLevel ) {
        try {
            return getDRLLexer(encoding != null ? new ANTLRInputStream(is, encoding) : new ANTLRInputStream(is), languageLevel);
        } catch ( final Exception e ) {
            throw new RuntimeException( "Unable to parser Reader", e );
        }
    }
View Full Code Here


        }
    }

    public static DRLParser buildParser( final InputStream is, final String encoding, LanguageLevelOption languageLevel ) {
        try {
            return buildParser(encoding != null ? new ANTLRInputStream(is, encoding) : new ANTLRInputStream(is), languageLevel);
        } catch ( final Exception e ) {
            throw new RuntimeException( "Unable to parser Reader", e );
        }
    }
View Full Code Here

    private Tree parse(String expression)
    {
        InputStream is = new ByteArrayInputStream(expression.getBytes());

        ANTLRInputStream ais;

        try
        {
            ais = new ANTLRInputStream(is);
        } catch (IOException ex)
        {
            throw new RuntimeException(ex);
        }
View Full Code Here

        String smaliFile = String.format("LexerTest%s%s.smali", File.separatorChar, test);
        String tokensFile = String.format("LexerTest%s%s.tokens", File.separatorChar, test);

        expectedTokensTestGrammarLexer expectedTokensLexer = null;
        try {
            expectedTokensLexer = new expectedTokensTestGrammarLexer(new ANTLRInputStream(
                    LexerTest.class.getClassLoader().getResourceAsStream(tokensFile)));
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
View Full Code Here

        NodeTestDSLParser parser = new NodeTestDSLParser( new CommonTokenStream( lexer ) );
        return parser;
    }

    private static NodeTestDSLParser getParser(final InputStream is) throws IOException {
        NodeTestDSLLexer lexer = new NodeTestDSLLexer( new ANTLRInputStream( is ) );
        NodeTestDSLParser parser = new NodeTestDSLParser( new CommonTokenStream( lexer ) );
        return parser;
    }
View Full Code Here

        }
    }

    private DRLParser getParser(final InputStream is) {
        try {
            lexer = new DRLLexer( new ANTLRInputStream( is ) );
            DRLParser parser = new DRLParser( new CommonTokenStream( lexer ));
            parser.setTreeAdaptor( new DroolsTreeAdaptor() );
            return parser;
        } catch ( final Exception e ) {
            throw new RuntimeException( "Unable to parser Reader",
View Full Code Here

    }
    public abstract void registerOptions(CommandProcessor options);
    public abstract TokenRenderer createRenderer(CommandProcessor options, File outFile);
   
    private void render(InputStream is, TokenRenderer renderer, PrintStream out) throws Exception {
        ANTLRInputStream input = new ANTLRInputStream(is);
        JavaLexer lexer = new JavaLexer(input);
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        DebugEventListener builder = new ParseTokenListener(renderer, out);
        JavaParser parser = new JavaParser(tokens, builder);
        // launch the parser starting at compilation unit
View Full Code Here

  private RutaModule loadScriptIS(String scriptLocation) throws IOException, RecognitionException {
    InputStream scriptInputStream = getClass().getClassLoader().getResourceAsStream(scriptLocation);
    if (scriptInputStream == null) {
      throw new FileNotFoundException("No script found in location [" + scriptLocation + "]");
    }
    CharStream st = new ANTLRInputStream(scriptInputStream, scriptEncoding);
    RutaLexer lexer = new RutaLexer(st);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    RutaParser parser = new RutaParser(tokens);
    parser.setExternalFactory(factory);
    parser.setResourcePaths(resourcePaths);
View Full Code Here

import org.antlr.runtime.tree.CommonTree;

public class TestCMinusParser {

  public static void main(String[] argv) throws Exception{
    ANTLRInputStream input = new ANTLRInputStream(System.in);
    CMinusLexer lexer = new CMinusLexer(input);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    CMinusParser parser = new CMinusParser(tokens);
    CMinusParser.program_return r = parser.program();
    CommonTree t = (CommonTree)r.getTree();
View Full Code Here

public class TestRewrite {
    public static void main(String[] args) throws Exception {

        // PARSE INPUT AND BUILD AST
        ANTLRInputStream input = new ANTLRInputStream(System.in);
        CMinusLexer lexer = new CMinusLexer(input);       // create lexer
        // create a buffer of tokens pulled from the lexer
        // Must use TokenRewriteStream not CommonTokenStream!
        TokenRewriteStream tokens = new TokenRewriteStream(lexer);
        CMinusParser parser = new CMinusParser(tokens);   // create parser
View Full Code Here

TOP

Related Classes of org.antlr.runtime.ANTLRInputStream

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.