Package org.antlr.runtime

Examples of org.antlr.runtime.ANTLRStringStream


public class DRLFactory {

    private DRLFactory() { }

    public static DRLLexer buildLexer(String text, LanguageLevelOption languageLevel) {
        return getDRLLexer(new ANTLRStringStream(text), languageLevel);
    }
View Full Code Here


    public static DRLParser buildParser(CharStream input, LanguageLevelOption languageLevel) {
        return buildParser(getDRLLexer( input, languageLevel ), languageLevel);
    }

    public static DRLParser buildParser(String text, LanguageLevelOption languageLevel) {
        return buildParser(new ANTLRStringStream(text), languageLevel);
    }
View Full Code Here

    }

    @Test
    public void testChunkWithoutParens() throws Exception {
        String input = "( foo )";
        createParser( new ANTLRStringStream( input ) );
        String returnData = parser.chunk( DRL6Lexer.LEFT_PAREN,
                                          DRL6Lexer.RIGHT_PAREN,
                                          -1 );

        assertEquals( "foo",
View Full Code Here

    }

    @Test
    public void testChunkWithParens() throws Exception {
        String input = "(fnord())";
        createParser( new ANTLRStringStream( input ) );
        String returnData = parser.chunk( DRL6Lexer.LEFT_PAREN,
                                          DRL6Lexer.RIGHT_PAREN,
                                          -1 );

        assertEquals( "fnord()",
View Full Code Here

    }

    @Test
    public void testChunkWithParensAndQuotedString() throws Exception {
        String input = "( fnord( \"cheese\" ) )";
        createParser( new ANTLRStringStream( input ) );
        String returnData = parser.chunk( DRL6Lexer.LEFT_PAREN,
                                          DRL6Lexer.RIGHT_PAREN,
                                          -1 );

        assertEquals( "fnord( \"cheese\" )",
View Full Code Here

    }

    @Test
    public void testChunkWithRandomCharac5ters() throws Exception {
        String input = "( %*9dkj)";
        createParser( new ANTLRStringStream( input ) );
        String returnData = parser.chunk( DRL6Lexer.LEFT_PAREN,
                                          DRL6Lexer.RIGHT_PAREN,
                                          -1 );

        assertEquals( "%*9dkj",
 
View Full Code Here

    }

    private Object parse( final String parserRuleName,
                          final String text ) throws Exception {
        return execParser( parserRuleName,
                           new ANTLRStringStream( text ) );
    }
View Full Code Here

    translator.rf = rf;
        factory.getGrammar().tool.log("action-translator", "translate " + action);
    String altLabel = node.getAltLabel();
    if ( rf!=null ) translator.nodeContext = rf.ruleCtx;
    if ( altLabel!=null ) translator.nodeContext = rf.altLabelCtxs.get(altLabel);
    ANTLRStringStream in = new ANTLRStringStream(action);
    in.setLine(tokenWithinAction.getLine());
    in.setCharPositionInLine(tokenWithinAction.getCharPositionInLine());
    ActionSplitter trigger = new ActionSplitter(in, translator);
    // forces eval, triggers listener methods
    trigger.getActionTokens();
    return translator.chunks;
  }
View Full Code Here

  String ruleName,
  String input,
  int scriptLine)
  throws Exception
  {
    ANTLRStringStream is = new ANTLRStringStream(input);
    Class<? extends TokenSource> lexerClass = Class.forName(lexerClassName).asSubclass(TokenSource.class);
    Constructor<? extends TokenSource> lexConstructor = lexerClass.getConstructor(CharStream.class);
    TokenSource lexer = lexConstructor.newInstance(is);
    is.setLine(scriptLine);

    CommonTokenStream tokens = new CommonTokenStream(lexer);

    Class<? extends Parser> parserClass = Class.forName(parserClassName).asSubclass(Parser.class);
    Constructor<? extends Parser> parConstructor = parserClass.getConstructor(TokenStream.class);
View Full Code Here

        }
    }

    public void examineAction() {
    //System.out.println("examine "+actionToken);
        ANTLRStringStream in = new ANTLRStringStream(actionToken.getText());
        in.setLine(actionToken.getLine());
        in.setCharPositionInLine(actionToken.getCharPositionInLine());
        ActionSplitter splitter = new ActionSplitter(in, this);
    // forces eval, triggers listener methods
        node.chunks = splitter.getActionTokens();
    }
View Full Code Here

TOP

Related Classes of org.antlr.runtime.ANTLRStringStream

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.