From 52c656a62d05135cf6ffd80249d5a44a07a40816 Mon Sep 17 00:00:00 2001 From: graehl Date: Tue, 10 Aug 2010 02:29:56 +0000 Subject: parse trule(string) using lexer - needs testing, affects earley_composer git-svn-id: https://ws10smt.googlecode.com/svn/trunk@497 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/trule.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'decoder/trule.cc') diff --git a/decoder/trule.cc b/decoder/trule.cc index 170e3a95..330db67f 100644 --- a/decoder/trule.cc +++ b/decoder/trule.cc @@ -4,6 +4,8 @@ #include "stringlib.h" #include "tdict.h" +#include "rule_lexer.h" +#include "threadlocal.h" using namespace std; @@ -91,7 +93,29 @@ TRule* TRule::CreateRuleMonolingual(const string& rule) { return new TRule(rule, false, true); } +namespace { +// callback for lexer +THREADLOCAL int n_assigned=0; +void assign_trule(const TRulePtr& new_rule, const unsigned int ctf_level, const TRulePtr& coarse_rule, void* extra) { + TRule *assignto=(TRule *)extra; + *assignto=*new_rule; +} + +} + bool TRule::ReadFromString(const string& line, bool strict, bool mono) { + if (!is_single_line_stripped(line)) + std::cerr<<"\nWARNING: building rule from multi-line string "<1) + std::cerr<<"\nWARNING: more than one rule parsed from multi-line string; kept last: "<