ilog.rules.brl.parsing

Class IlrBRLParserManager

  • java.lang.Object
    • ilog.rules.brl.parsing.IlrBRLParserManager
  • All Implemented Interfaces:
    IlrBRLParser, IlrBRLParserService, ilog.rules.brl.parsing.IlrBRLParserServiceExtension


    public class IlrBRLParserManager
    extends java.lang.Object
    implements IlrBRLParserService, ilog.rules.brl.parsing.IlrBRLParserServiceExtension
    IlrBRLParserManager is used to create a BRL parser manager.

    This parser manager depends on a vocabulary manager instance in order to:

    • Return a vocabulary for a locale.
    • Provide notification when a vocabulary has been modified.
    If the vocabulary manager is a BRL Vocabulary Manager, it can also provides a boot vocabulary for a given language. You can use a parser manager instance to create and retrieve BRL parsers. This parser manager implements the IlrBRLParserService interface. It provides methods for parsing a BRL input.

    See Also:
    IlrVocabularyManager, IlrBRLVocabularyManager, IlrBRLParserService
    • Constructor Detail

      • IlrBRLParserManager

        public IlrBRLParserManager(IlrVocabulary vocabulary)
        Creates a BRL parser manager that can be used with a unique immutable vocabulary.

        The parser manager is created from the given vocabulary. The parser manager created by this constructor can only be used for the Locale of this vocabulary and becomes invalid when this vocabulary is changed. If a multi-locale support is required or if the vocabulary can be changed, use the other constructors of this class.

        Parameters:
        vocabulary - a non-null Vocabulary object
      • IlrBRLParserManager

        public IlrBRLParserManager(IlrVocabularyManager vocabularyManager)
        Creates a BRL parser manager.

        The parser manager depends on a vocabulary manager able to return a vocabulary from a locale and provide notification when a vocabulary has been modified. A parser manager is able to create and retrieve BRL parsers.

        Parameters:
        vocabularyManager - The vocabulary manager.
        See Also:
        IlrVocabularyManager
      • IlrBRLParserManager

        public IlrBRLParserManager(IlrVocabularyManager vocabularyManager,
                           java.lang.Object lock)
        Creates a BRL parser manager.

        The parser manager depends on a vocabulary manager able to return a vocabulary from a locale and provide notification when a vocabulary has been modified. A parser manager is able to create and retrieve BRL parsers. A lock can be passed to this parser manager. If null the parser itself will be used to control MT access to the parsing session.

        Parameters:
        vocabularyManager - The vocabulary manager.
        lock - A preferred lock object used to synchronize manipulations of the parsers.
        See Also:
        IlrVocabularyManager
    • Method Detail

      • getVocabularyManager

        public IlrVocabularyManager getVocabularyManager()
        This method returns the vocabulary manager associated to this parser manager.
        Returns:
        the vocabulary manager used by this parser manager.
      • getVocabulary

        public IlrVocabulary getVocabulary(IlrBRLDefinition definition,
                                  java.util.Locale locale)
        This method returns the vocabulary of the parser managed by this parser manager corresponding to the given language and the given locale.
        Specified by:
        getVocabulary in interface IlrBRLParserService
        Parameters:
        definition - the language
        locale - the locale
        Returns:
        the vocabulary associated to this parser
      • getVocabulary

        public IlrVocabulary getVocabulary(java.util.Locale locale)
        Deprecated. use getVocabulary(IlrBRLDefinition definition, Locale locale)
        This method returns the vocabulary associated to this parser manager for the given locale. It suppose that the VocabularyManager associated to this parser manager is not a BRL Vocabulary manager or does not return language-specific boot vocabulary It throws IllegalArgumentException exception if the given locale is not supported by the Vocabulary manager associated to this parser manager.
        Specified by:
        getVocabulary in interface IlrBRLParser
        Throws:
        java.lang.IllegalArgumentException
        Parameters:
        locale - The locale to check.
        Returns:
        the vocabulary manager used by this parser manager.
      • isLexicalCheckerEnabled

        public boolean isLexicalCheckerEnabled()
        Returns true if the lexical checker is enabled.
        Returns:
        true Lexical checker is enabled.
      • setLexicalCheckerEnabled

        public void setLexicalCheckerEnabled(boolean lexicalChecker)
        Enables or disables the lexical checker.

        The lexical checker can detect conflict in generated grammar that may generate erroneous lexical interpretations during interpretation of rules. Errors are reported by the grammar generator error reporter.

        Parameters:
        lexicalChecker -
        See Also:
        IlrBRLGrammarGeneratorErrorReporter
      • getGrammarGeneratorErrorReporter

        public IlrBRLGrammarGeneratorErrorReporter getGrammarGeneratorErrorReporter()
        Returns the grammar generator error reporter.
        Returns:
        the grammar generator error reporter
      • setGrammarGeneratorErrorReporter

        public void setGrammarGeneratorErrorReporter(IlrBRLGrammarGeneratorErrorReporter grammarGeneratorErrorReporter)
        Sets the grammar generator error reporter that will handle grammar generator errors.
        Parameters:
        grammarGeneratorErrorReporter - The grammar generator error reporter.
        See Also:
        IlrBRLGrammarGeneratorError
      • getDefinition

        public IlrBRLDefinition getDefinition(java.lang.String definitionName,
                                     java.util.Locale locale)
        This method returns the BRL Definition associated to the given language and the given locale.
        Parameters:
        definitionName -
        locale -
        Returns:
        the definition or null if the definition has not been loaded correctly or if the language is not registered
      • parse

        public IlrSyntaxTree parse(IlrBRLParserInput input,
                          IlrBRLParserConfiguration configuration)
        Deprecated. use parse(rule, configuration, predictionConfiguration)
        Parse a rule to retrieve a representation of the rule as a syntax tree.

        The rule is parsed according to the BRL parser configuration given as an argument (configuration).

        Parameters:
        input - The rule to parse.
        configuration - The configuration of parser to parse the rule.
        Returns:
        The syntax tree of the rule.
        See Also:
        IlrSyntaxTree, IlrBRLParserConfiguration
      • dispose

        public void dispose()
        This method should be called when the parser manager is not useful anymore. It removes its subscription to the vocabulary manager that was used to create it.
      • getSyncLock

        public java.lang.Object getSyncLock()
        Returns the mutex used to synchronize manipulation of the parsers managed by this parser manager. If none is assigned to this parser manager, the parser itself will be used to control MT access to the parsing session.
        Returns:
        the mutex associated to this parser manager or null if none has been set.

© Copyright IBM Corp. 1987, 2017