Skip to content
Snippets Groups Projects
Select Git revision
  • 03510c7e7ad9cb3a8c0033cb25523ccd8a11c1fd
  • master default protected
  • vertical_relations
  • lu_without_semantic_frames
  • hierarchy
  • additional-unification-filters
  • v0.1.1
  • v0.1.0
  • v0.0.9
  • v0.0.8
  • v0.0.7
  • v0.0.6
  • v0.0.5
  • v0.0.4
  • v0.0.3
  • v0.0.2
  • v0.0.1
17 results

models.py

Blame
  • Parser.cpp 3.07 KiB
    #include <libwccl/parser/Parser.h>
    
    /**
     * @desc Parser constructor. Default tagset is NULL
     */
    Parser::Parser(const Corpus2::Tagset& t) : tagset(t)
    {
    }
    
    /**
     *
     */
    Parser::~Parser()
    {
    	//
    }
    
    // ----------------------------------------------------------------------------
    /**
     * @desc Parse string operator writed in std::string. Converts writed operator
     *       to istream and calling parseStringOperator with istream
     * @arg str writed operator
     * @retrun boost::shared_ptr<Wccl::StrSet>
     */
    boost::shared_ptr<ANTLRParserResult<Wccl::StrSet> > Parser::parseStringOperator(
    		const std::string& str) const
    {
    	std::stringstream ss (std::stringstream::in | std::stringstream::out);
    	ss << str;
    
    	return this->parseStringOperator(ss);
    }
    
    /**
     * @desc Parse string operator. Runs parse_string_operator rule
     *       in the parser grammar.
     * @arg istr input stream with writed operator
     * @return boost::shared_ptr<Wccl::Function<Wccl::StrSet> > to created operator
     */
    boost::shared_ptr<ANTLRParserResult<Wccl::StrSet> > Parser::parseStringOperator(
    		std::istream& istr) const
    {
    	ANTLRLexer lexer(istr);
    	ANTLRParser parser(lexer);
    
    	return parser.parse_string_operator();
    }
    
    // ----------------------------------------------------------------------------
    /**
     * @desc Parse predicates writed in std::string. Converts writed predicates
     *       to istream and calling parsePredicate with istream
     * @arg str writed predicate(s)
     * @return boost::shared_ptr<Wccl::Function<Wccl::Bool> > to created predicate
     */
    boost::shared_ptr<ANTLRParserResult<Wccl::Bool> > Parser::parsePredicate(
    		const std::string& str) const
    {
    	std::stringstream ss (std::stringstream::in | std::stringstream::out);
    	ss << str;
    
    	return this->parsePredicate(ss);
    }
    
    /**
     * @desc Parse predicate. Runs parse_predicates rule in the parser grammar.
     * @arg istr input stream with writed predicate
     * @return boost::shared_ptr<Wccl::Function<Wccl::Bool> > to created predicate
     */
    boost::shared_ptr<ANTLRParserResult<Wccl::Bool> > Parser::parsePredicate(
    		std::istream& istr) const
    {
    	ANTLRLexer lexer(istr);
    	ANTLRParser parser(lexer);
    
    	return parser.parse_predicates();
    }
    
    // ----------------------------------------------------------------------------
    /**
     * @desc Parse sym set operator writed in std::string. Converts writed operator
     *       to istream and calling parseSymSetOperator with istream
     * @arg str writed operator
     * @retrun boost::shared_ptr<Wccl::Function<Wccl::TSet> >
     */
    boost::shared_ptr<ANTLRParserResult<Wccl::TSet> > Parser::parseSymSetOperator(
    		const std::string& str) const
    {
    	std::stringstream ss (std::stringstream::in | std::stringstream::out);
    	ss << str;
    
    	return this->parseSymSetOperator(ss);
    }
    
    /**
     * @desc Parse sym set operator. Runs parse_sym_set_operator rule
     *       in the parser grammar.
     * @arg istr input stream with writed operator
     * @return boost::shared_ptr<Wccl::Function<Wccl::TSet> > to created operator
     */
    boost::shared_ptr<ANTLRParserResult<Wccl::TSet> > Parser::parseSymSetOperator(
    		std::istream& istr) const
    {
    	ANTLRLexer lexer(istr);
    	ANTLRParser parser(lexer);
    
    	return parser.parse_sym_set_operator();
    }