org.cesta.util.antlr.java
Class ANTLRJavaHelper

java.lang.Object
  extended by org.cesta.util.antlr.java.ANTLRJavaHelper

public class ANTLRJavaHelper
extends java.lang.Object

ANTLRJavaHelper provides some helper functions for simplified access to JavaLexer and JavaParser, which are part of the framework.

Author:
Tobias Smolka

Constructor Summary
ANTLRJavaHelper()
           
 
Method Summary
static java.util.List<org.antlr.runtime.Token> getIndent(org.antlr.runtime.TokenRewriteStream tokenStream, org.antlr.runtime.Token baseToken)
          Returns indent tokens, which are before baseToken in tokenStream.
static java.lang.String getTypeDefaultValue(java.lang.String type)
          Helper function, that returns default value for given type
static void checkSyntax(org.antlr.runtime.TokenStream tokens)
          Try to parse source code and check for errors in transformations
static org.antlr.runtime.tree.CommonTree parseStream(org.antlr.runtime.TokenStream tokens)
          Instantiates JavaParser on provided tokens, parses the code and returns parsed abstract syntax tree (AST)
static JavaLexer tokenizeStream(org.antlr.runtime.CharStream stream)
          Instantiates JavaLexer on provided stream - it will try to tokenize the input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ANTLRJavaHelper

public ANTLRJavaHelper()
Method Detail

tokenizeStream

public static JavaLexer tokenizeStream(org.antlr.runtime.CharStream stream)
                                throws TransformationException
Instantiates JavaLexer on provided stream - it will try to tokenize the input.

Parameters:
stream - string stream which should be tokenized
Returns:
lexer
Throws:
TransformationException

parseStream

public static org.antlr.runtime.tree.CommonTree parseStream(org.antlr.runtime.TokenStream tokens)
                                                     throws TransformationException
Instantiates JavaParser on provided tokens, parses the code and returns parsed abstract syntax tree (AST)

Parameters:
tokens -
Returns:
parsed AST
Throws:
TransformationException - in case that source code could not be parsed

checkSyntax

public static void checkSyntax(org.antlr.runtime.TokenStream tokens)
                        throws TransformationException
Try to parse source code and check for errors in transformations

Parameters:
tokens - Tokens to be parsed
Throws:
TransformationException - in case that tokens couldn't be parsed

getIndent

public static java.util.List<org.antlr.runtime.Token> getIndent(org.antlr.runtime.TokenRewriteStream tokenStream,
                                                                org.antlr.runtime.Token baseToken)
Returns indent tokens, which are before baseToken in tokenStream.

Returns:
list of tokens

getTypeDefaultValue

public static java.lang.String getTypeDefaultValue(java.lang.String type)
Helper function, that returns default value for given type. *

Parameters:
type - type of return value
Returns:
sample return value