/** * Creates a normalizing subtree specification parser. * * @param resolver The resolver to use * @param schemaManager The SchemaManager */ public SubtreeSpecificationParser( @SuppressWarnings("rawtypes") NormalizerMappingResolver resolver, SchemaManager schemaManager ) { // place holder for the first input StringReader in = new StringReader( "" ); this.lexer = new ReusableAntlrSubtreeSpecificationLexer( in ); this.parser = new ReusableAntlrSubtreeSpecificationParser( lexer ); this.parser.setNormalizerMappingResolver( resolver ); // this method MUST be called while we cannot do // constructor overloading for antlr generated parser this.parser.init( schemaManager ); this.isNormalizing = true; }
/** * Resets the state of an antlr parser. */ public void resetState() { // no set method for this protected field. this.traceDepth = 0; this.getInputState().reset(); } }
/** * Initializes the plumbing by creating a pipe and coupling the parser/lexer * pair with it. * * @param spec The specification to parse */ private synchronized void reset( String spec ) { // append end of input token StringReader in = new StringReader( spec + "end" ); this.lexer.prepareNextInput( in ); this.parser.resetState(); }
/** * Creates a subtree specification parser. * * @param schemaManager The SchemaManager */ public SubtreeSpecificationParser( SchemaManager schemaManager ) { // place holder for the first input StringReader in = new StringReader( "" ); this.lexer = new ReusableAntlrSubtreeSpecificationLexer( in ); this.parser = new ReusableAntlrSubtreeSpecificationParser( lexer ); // this method MUST be called while we cannot do // constructor overloading for antlr generated parser this.parser.init( schemaManager ); this.isNormalizing = false; }
/** * Parses a subtree specification without exhausting the parser. * * @param spec * the specification to be parsed * @return the specification bean * @throws ParseException * if there are any recognition errors (bad syntax) */ public synchronized SubtreeSpecification parse( String spec ) throws ParseException { SubtreeSpecification ss; if ( ( spec == null ) || Strings.isEmpty( spec.trim() ) ) { return null; } // reset and initialize the parser / lexer pair reset( spec ); try { ss = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException | RecognitionException e ) { String msg = I18n.err( I18n.ERR_13028_SUBTREE_SPEC_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } return ss; }
/** * Creates a subtree specification parser. * * @param schemaManager The SchemaManager */ public SubtreeSpecificationParser( SchemaManager schemaManager ) { // place holder for the first input StringReader in = new StringReader( "" ); this.lexer = new ReusableAntlrSubtreeSpecificationLexer( in ); this.parser = new ReusableAntlrSubtreeSpecificationParser( lexer ); // this method MUST be called while we cannot do // constructor overloading for antlr generated parser this.parser.init( schemaManager ); this.isNormalizing = false; }
/** * Parses a subtree specification without exhausting the parser. * * @param spec * the specification to be parsed * @return the specification bean * @throws ParseException * if there are any recognition errors (bad syntax) */ public synchronized SubtreeSpecification parse( String spec ) throws ParseException { SubtreeSpecification ss; if ( ( spec == null ) || Strings.isEmpty( spec.trim() ) ) { return null; } // reset and initialize the parser / lexer pair reset( spec ); try { ss = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException | RecognitionException e ) { String msg = I18n.err( I18n.ERR_13028_SUBTREE_SPEC_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } return ss; }
/** * Creates a normalizing subtree specification parser. * * @param resolver The resolver to use * @param schemaManager The SchemaManager */ public SubtreeSpecificationParser( @SuppressWarnings("rawtypes") NormalizerMappingResolver resolver, SchemaManager schemaManager ) { // place holder for the first input StringReader in = new StringReader( "" ); this.lexer = new ReusableAntlrSubtreeSpecificationLexer( in ); this.parser = new ReusableAntlrSubtreeSpecificationParser( lexer ); this.parser.setNormalizerMappingResolver( resolver ); // this method MUST be called while we cannot do // constructor overloading for antlr generated parser this.parser.init( schemaManager ); this.isNormalizing = true; }
/** * Creates a subtree specification parser. * * @param schemaManager The SchemaManager */ public SubtreeSpecificationParser( SchemaManager schemaManager ) { // place holder for the first input StringReader in = new StringReader( "" ); this.lexer = new ReusableAntlrSubtreeSpecificationLexer( in ); this.parser = new ReusableAntlrSubtreeSpecificationParser( lexer ); // this method MUST be called while we cannot do // constructor overloading for antlr generated parser this.parser.init( schemaManager ); this.isNormalizing = false; }
/** * Resets the state of an antlr parser. */ public void resetState() { // no set method for this protected field. this.traceDepth = 0; this.getInputState().reset(); } }
/** * Initializes the plumbing by creating a pipe and coupling the parser/lexer * pair with it. * * @param spec The specification to parse */ private synchronized void reset( String spec ) { // append end of input token StringReader in = new StringReader( spec + "end" ); this.lexer.prepareNextInput( in ); this.parser.resetState(); }
/** * Parses a subtree specification without exhausting the parser. * * @param spec * the specification to be parsed * @return the specification bean * @throws ParseException * if there are any recognition errors (bad syntax) */ public synchronized SubtreeSpecification parse( String spec ) throws ParseException { SubtreeSpecification ss; if ( ( spec == null ) || Strings.isEmpty( spec.trim() ) ) { return null; } // reset and initialize the parser / lexer pair reset( spec ); try { ss = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException | RecognitionException e ) { String msg = I18n.err( I18n.ERR_13028_SUBTREE_SPEC_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } return ss; }
/** * Creates a normalizing subtree specification parser. * * @param resolver The resolver to use * @param schemaManager The SchemaManager */ public SubtreeSpecificationParser( @SuppressWarnings("rawtypes") NormalizerMappingResolver resolver, SchemaManager schemaManager ) { // place holder for the first input StringReader in = new StringReader( "" ); this.lexer = new ReusableAntlrSubtreeSpecificationLexer( in ); this.parser = new ReusableAntlrSubtreeSpecificationParser( lexer ); this.parser.setNormalizerMappingResolver( resolver ); // this method MUST be called while we cannot do // constructor overloading for antlr generated parser this.parser.init( schemaManager ); this.isNormalizing = true; }
/** * Resets the state of an antlr parser. */ public void resetState() { // no set method for this protected field. this.traceDepth = 0; this.getInputState().reset(); } }
/** * Initializes the plumbing by creating a pipe and coupling the parser/lexer * pair with it. * * @param spec The specification to parse */ private synchronized void reset( String spec ) { // append end of input token StringReader in = new StringReader( spec + "end" ); this.lexer.prepareNextInput( in ); this.parser.resetState(); }