Skip to content
Snippets Groups Projects
libcclparser.i 3.04 KiB
#ifndef SWIG_LIBCCL_PARSER_I
#define SWIG_LIBCCL_PARSER_I

%module libcclparser
%{
  #include <libwccl/parser/Parser.h>
%}

%include "libcclbool.i"
%include "libccltset.i"
%include "libcclstrset.i"
%include "libcclposition.i"
%include "libccloperator.i"
// %include "libccltagrule.i"
// %include "libccltagrulesequence.i"
// %include "libcclmatchrule.i"
%include "libcclfunctionaloperator.i"

%include "libcorpus/libcorpustagset.i"

%include "std_string.i"
%include "std_vector.i"
%include "boost_shared_ptr.i"

namespace Wccl {
  class Parser {
  public:
    explicit Parser(const Corpus2::Tagset&);
    explicit Parser(const std::string& tagset_name);
    ~Parser();

    /* --------------------------------------------------------------------- */

    %exception {
      try {
        $action
      } catch (PwrNlp::PwrNlpError &e) {
        PyErr_SetString(PyExc_IndexError, e.info().c_str());
        return NULL;
      }
    }
    shared_ptr<Operator<StrSet> > 
      parseStringOperator (const std::string& operator_string) const;

    %exception {
      try {
        $action
      } catch (PwrNlp::PwrNlpError &e) {
        PyErr_SetString(PyExc_IndexError, e.info().c_str());
        return NULL;
      }
    }
    shared_ptr<Operator<Bool> > 
      parseBoolOperator (const std::string& operator_string) const;

    %exception {
      try {
        $action
      } catch (PwrNlp::PwrNlpError &e) {
        PyErr_SetString(PyExc_IndexError, e.info().c_str());
        return NULL;
      }
    }
    shared_ptr<Operator<TSet> > 
      parseSymSetOperator (const std::string& operator_string) const;

    %exception {
      try {
        $action
      } catch (PwrNlp::PwrNlpError &e) {
        PyErr_SetString(PyExc_IndexError, e.info().c_str());
        return NULL;
      }
    }
    shared_ptr<Operator<Position> > 
      parsePositionOperator(const std::string& operator_string) const;

    /* --------------------------------------------------------------------- */

    %exception {
      try {
        $action
      } catch (PwrNlp::PwrNlpError &e) {
        PyErr_SetString(PyExc_IndexError, e.info().c_str());
        return NULL;
      }
    }
    shared_ptr<FunctionalOperator>  
      parseAnyOperator(const std::string& operator_string) const;

    /* --------------------------------------------------------------------- */
    // shared_ptr<TagRuleSequence>
    //  parseTagRuleSequence(const std::string& rule_string) const;

    // shared_ptr<TagRule>
    //   parseSingleRule(const std::string& rule_string) const;
    
    // boost::shared_ptr<MatchRule>
    //  parseMatchRule(const std::string& rule_string) const;

/*
 * NOT IMPLEMENTED YET!
 * ------------------------------------------------
    boost::shared_ptr<WcclFile> parseWcclFile(
        const std::string& file_contents_string,
        const std::string& search_path = ".") const;
 */

    /* --------------------------------------------------------------------- */

    const Corpus2::Tagset& tagset() const;
  };
}

using namespace boost;
using namespace std;
using namespace Corpus2;

#endif /* SWIG_LIBCCL_PARSER_I */