Search in sources :

Example 1 with TokenMgrError

use of japa.parser.TokenMgrError in project japid42 by branaway.

the class JavaSyntaxTool method parse.

public static CompilationUnit parse(String src) throws ParseException {
    ByteArrayInputStream in;
    try {
        in = new ByteArrayInputStream(src.getBytes(UTF_8));
        CompilationUnit cu;
        cu = JavaParser.parse(in, UTF_8);
        return cu;
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (TokenMgrError e) {
        throw new ParseException(e.getMessage());
    }
    return null;
}
Also used : CompilationUnit(japa.parser.ast.CompilationUnit) ByteArrayInputStream(java.io.ByteArrayInputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) TokenMgrError(japa.parser.TokenMgrError) ParseException(japa.parser.ParseException)

Example 2 with TokenMgrError

use of japa.parser.TokenMgrError in project Japid by branaway.

the class JavaSyntaxTool method parse.

public static CompilationUnit parse(String src) throws ParseException {
    ByteArrayInputStream in;
    try {
        in = new ByteArrayInputStream(src.getBytes(UTF_8));
        CompilationUnit cu;
        cu = JavaParser.parse(in, UTF_8);
        return cu;
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (TokenMgrError e) {
        throw new ParseException(e.getMessage());
    }
    return null;
}
Also used : CompilationUnit(japa.parser.ast.CompilationUnit) ByteArrayInputStream(java.io.ByteArrayInputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) TokenMgrError(japa.parser.TokenMgrError) ParseException(japa.parser.ParseException)

Aggregations

ParseException (japa.parser.ParseException)2 TokenMgrError (japa.parser.TokenMgrError)2 CompilationUnit (japa.parser.ast.CompilationUnit)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2