本文整理汇总了C++中parser_parse函数的典型用法代码示例。如果您正苦于以下问题:C++ parser_parse函数的具体用法?C++ parser_parse怎么用?C++ parser_parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parser_parse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s_s
JNIEXPORT jint JNICALL Java_edu_hit_ir_ltp4j_Parser_parse
(JNIEnv * env, jclass obj, jobject array_words, jobject array_tags, jobject array_heads, jobject array_deprels){
jclass array_list = env->GetObjectClass(array_words);
jclass integer = env->FindClass("java/lang/Integer");
jmethodID list_add = env->GetMethodID(array_list,"add","(Ljava/lang/Object;)Z");
jmethodID list_get = env->GetMethodID(array_list,"get","(I)Ljava/lang/Object;");
jmethodID list_size = env->GetMethodID(array_list,"size","()I");
jmethodID integer_init =env->GetMethodID(integer,"<init>","(I)V");
std::vector<std::string> words,tags,deprels;
std::vector<int> heads;
int size_words = env->CallIntMethod(array_words,list_size);
int size_tags = env->CallIntMethod(array_tags,list_size);
if(size_words!=size_tags) {
return -1;
}
for(int i = 0;i<size_words;i++){
jobject tmp = env->CallObjectMethod(array_words,list_get,i);
jstring s = reinterpret_cast<jstring> (tmp);
const char * st = env->GetStringUTFChars(s,0);
std::string s_s(st);
words.push_back(s_s);
env->ReleaseStringUTFChars( s, st);
}
for(int i = 0;i<size_tags;i++){
jobject tmp = env->CallObjectMethod(array_tags,list_get,i);
jstring s = reinterpret_cast<jstring> (tmp);
const char * st = env->GetStringUTFChars(s,0);
std::string s_s(st);
tags.push_back(s_s);
env->ReleaseStringUTFChars( s, st);
}
int len = parser_parse(parser,words,tags,heads,deprels);
if(len<0)
{
return -1;
}
int size = heads.size();
for(int i = 0;i<size;i++){
jobject integer_object = env->NewObject(integer,integer_init,heads.at(i));
env->CallBooleanMethod(array_heads,list_add, integer_object);
}
for(int i = 0;i<size;i++){
jobject tmp = stringToJstring(env,deprels[i].c_str());
env->CallBooleanMethod(array_deprels,list_add,tmp);
}
return len;
}
示例2: test_name0
int test_name0(void *state) {
enum parser_error r = parser_parse(state, "name:of Resist Lightning");
struct ego_item *e;
eq(r, PARSE_ERROR_NONE);
e = parser_priv(state);
require(e);
require(streq(e->name, "of Resist Lightning"));
ok;
}
示例3: test_rand0
int test_rand0(void *state) {
int wasok = 0;
errr r = parser_reg(state, "test-rand0 rand r0", helper_rand0);
eq(r, 0);
parser_setpriv(state, &wasok);
r = parser_parse(state, "test-rand0:2d3");
eq(r, 0);
eq(wasok, 1);
ok;
}
示例4: test_int1
int test_int1(void *state) {
int wasok = 0;
errr r = parser_reg(state, "test-int1 int i0", helper_int1);
eq(r, 0);
parser_setpriv(state, &wasok);
r = parser_parse(state, "test-int1:-3");
eq(r, PARSE_ERROR_NONE);
eq(wasok, 1);
ok;
}
示例5: test_sym1
int test_sym1(void *state) {
int wasok = 0;
errr r = parser_reg(state, "test-sym1 sym foo sym baz", helper_sym1);
eq(r, 0);
parser_setpriv(state, &wasok);
r = parser_parse(state, "test-sym1:bar:quxx");
eq(r, PARSE_ERROR_NONE);
eq(wasok, 1);
ok;
}
示例6: test_skill_shoot0
int test_skill_shoot0(void *state) {
enum parser_error r = parser_parse(state, "skill-shoot:6");
struct player_race *pr;
eq(r, PARSE_ERROR_NONE);
pr = parser_priv(state);
require(pr);
eq(pr->r_skills[SKILL_TO_HIT_BOW], 6);
ok;
}
示例7: test_skill_stealth0
int test_skill_stealth0(void *state) {
enum parser_error r = parser_parse(state, "skill-stealth:7");
struct player_race *pr;
eq(r, PARSE_ERROR_NONE);
pr = parser_priv(state);
require(pr);
eq(pr->r_skills[SKILL_STEALTH], 7);
ok;
}
示例8: test_skill_device0
int test_skill_device0(void *state) {
enum parser_error r = parser_parse(state, "skill-device:3");
struct player_race *pr;
eq(r, PARSE_ERROR_NONE);
pr = parser_priv(state);
require(pr);
eq(pr->r_skills[SKILL_DEVICE], 3);
ok;
}
示例9: test_c0
static int test_c0(void *state) {
enum parser_error r = parser_parse(state, "C:v");
struct monster_race *mr;
eq(r, PARSE_ERROR_NONE);
mr = parser_priv(state);
require(mr);
eq(mr->d_attr, TERM_VIOLET);
ok;
}
示例10: test_t0
static int test_t0(void *state) {
enum parser_error r = parser_parse(state, "T:townsfolk");
struct monster_race *mr;
eq(r, PARSE_ERROR_NONE);
mr = parser_priv(state);
require(mr);
require(streq(mr->base->name, "townsfolk"));
ok;
}
示例11: test_f0
static int test_f0(void *state) {
enum parser_error r = parser_parse(state, "F:UNIQUE | MALE");
struct monster_race *mr;
eq(r, PARSE_ERROR_NONE);
mr = parser_priv(state);
require(mr);
require(mr->flags);
ok;
}
示例12: test_f0
static int test_f0(void *state) {
errr r = parser_parse(state, "F:STR");
struct object_kind *k;
eq(r, 0);
k = parser_priv(state);
require(k);
require(k->flags);
ok;
}
示例13: test_c0
int test_c0(void *state) {
enum parser_error r = parser_parse(state, "C:1|3|5");
struct player_race *pr;
eq(r, PARSE_ERROR_NONE);
pr = parser_priv(state);
require(pr);
eq(pr->choice, (1 << 5) | (1 << 3) | (1 << 1));
ok;
}
示例14: main
main(int argc, char **argv){
if(argc < 2)
printf("Nothing to do\n");
else
avrsh_init();
parser_parse(argv[1]);
avrsh_shutdown();
printf("Success\n");
return 0;
}
示例15: test_flags0
int test_flags0(void *state) {
enum parser_error r = parser_parse(state, "flags:SEE_INVIS");
struct ego_item *e;
eq(r, PARSE_ERROR_NONE);
e = parser_priv(state);
require(e);
require(e->flags);
ok;
}