public TregexPattern compile ( String tregex ) { for ( Pair < String , String > macro : macros ) { tregex = tregex . replaceAll ( macro . first ( ) , macro . second ( ) ) ; } TregexPattern pattern ; try { TregexParser parser = new TregexParser ( new StringReader ( tregex + ' ' ) , basicCatFunction , headFinder ) ; pattern = parser . Root ( ) ; } catch ( TokenMgrError tme ) { throw new TregexParseException ( "Could not parse " + tregex , tme ) ; } catch ( ParseException e ) { throw new TregexParseException ( "Could not parse " + tregex , e ) ; } pattern . setPatternString ( tregex ) ; return pattern ; }
Create a TregexPattern from this tregex string using the headFinder and basicCat function this TregexPatternCompiler was created with .