/* // This file is created by Template of umsCodeGenerator version 0.3 candidate */ #include "textSample.h" /* // Definition of Variables */ extern struct Vector vect; extern int hasComment; extern char * comment; extern int hasComment; /* // Decoder Common Routines // // 2004/11/09 - release 0.1 - Created by KM // 2004/11/09 - release 0.2 - Modified by KM // 2004/12/25 - release 0.3 - Modified by KM // ums__txtCopy */ #include #include #include #include #include static int ums__found; static int ums__pos; static int ums__pos0; static char* ums__input; static int match (int label, int epos); static int match1(int label, int epos); static void die(char* msg){ fprintf(stderr,"%s\\n", msg); exit(1); } static char ums__output[4096]; static int ums__wpos=0; static void ums__readReset(){ ums__wpos = 0; } static void ums__txtCopy(int spos, int epos){ int cpos = ums__wpos; int len = (epos-spos)/8; strncpy( ums__output+ums__wpos, ums__input+spos/8, len ); ums__wpos += len; ums__output[ums__wpos] = 0; return ums__output+cpos; } static char *ums__txtRead(int spos, int epos){ int cpos = ums__wpos; int len = (epos-spos)/8; strncpy( ums__output+ums__wpos, ums__input+spos/8, len ); ums__wpos += len; ums__output[ums__wpos++] = 0; return ums__output+cpos; } static int64_t ums__signedRead(int spos, int epos){ int i,n = ums__input[spos/8]; int64_t tmp = ((n >> (7-spos%8)) & 1) * -1; for(i=spos+1; i < epos; i++ ){ int n = ums__input[i/8]; tmp = tmp * 2; tmp += (n >> (7-i%8)) & 1; } return tmp; } static uint64_t ums__unsignedRead(int spos, int epos){ int i,n = ums__input[spos/8]; uint64_t tmp = ((n >> (7-spos%8)) & 1); for(i=spos+1; i < epos; i++ ){ int n = ums__input[i/8]; tmp = tmp * 2; tmp += (n >> (7-i%8)) & 1; } return tmp; } static float ums__ieee754singleRead(int spos, int epos){ void *tmp = ums__input + spos/8; /* int i,n = ums__input[spos/8]; uint32_t tmp = ((n >> (7-spos%8)) & 1); for(i=spos+1; i < epos; i++ ){ int n = ums__input[i/8]; tmp = tmp * 2; tmp += (n >> (7-i%8)) & 1; } */ return *((float *)((void *)(tmp))); } static double ums__ieee754doubleRead(int spos, int epos){ void *tmp = ums__input + spos/8; /* int i,n = ums__input[spos/8]; uint64_t tmp = ((n >> (7-spos%8)) & 1); for(i=spos+1; i < epos; i++ ){ int n = ums__input[i/8]; tmp = tmp * 2; tmp += (n >> (7-i%8)) & 1; } */ return *((double *)((void *)(tmp))); } /* // Definition of Decoder (matcher) */ /* < oclng:decoderSub> */ static int match(int label, int epos1){ ums__pos0 = ums__pos; ums__found = match1(label, epos1); if(ums__found == 0 ){ ums__pos = ums__pos0; } return ums__found; } static int match1(int label, int epos1){ int level = -1; while(1){ /* < group> */ { int found1 = 0; if (level >= 0 || label == 4){ level++; } while(1){ /* < oclng:readerSub> */ /* < group> */ { int found2 = 0; if (level >= 0 || label == 8){ level++; } while(1){ /* < value> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 9){ level++; } if (level >= 0 && found){ int len = strlen("Vector"); char *str = ums__input+ums__pos/8; found = !strncmp(str,"Vector",len); eposd = ums__pos + len*8; } if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* < data> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 10){ level++; } /* < param> */ if (level >= 0 && found){ int stat; regex_t preg; size_t nmatch = 1; regmatch_t pmatch[1]; int eflags = 0; char *str = ums__input+ums__pos/8; char sav = ums__input[eposd/8]; ums__input[eposd/8] = 0; stat = regcomp(& preg, "^" "[ \\t]+", REG_EXTENDED); stat = regexec(& preg, str, nmatch, pmatch, eflags); ums__input[eposd/8] = sav; regfree(& preg); found = !stat; if(found){ eposd = ums__pos + 8*pmatch[0].rm_eo;} } /* */ if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* < data> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 13){ level++; } /* < param> */ if (level >= 0 && found){ int stat; regex_t preg; size_t nmatch = 1; regmatch_t pmatch[1]; int eflags = 0; char *str = ums__input+ums__pos/8; char sav = ums__input[eposd/8]; ums__input[eposd/8] = 0; stat = regcomp(& preg, "^" "[a-zA-Z_][a-zA-Z0-9_]*", REG_EXTENDED); stat = regexec(& preg, str, nmatch, pmatch, eflags); ums__input[eposd/8] = sav; regfree(& preg); found = !stat; if(found){ eposd = ums__pos + 8*pmatch[0].rm_eo;} } /* */ if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* < value> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 15){ level++; } if (level >= 0 && found){ int len = strlen("("); char *str = ums__input+ums__pos/8; found = !strncmp(str,"(",len); eposd = ums__pos + len*8; } if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* < data> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 16){ level++; } /* < param> */ if (level >= 0 && found){ int stat; regex_t preg; size_t nmatch = 1; regmatch_t pmatch[1]; int eflags = 0; char *str = ums__input+ums__pos/8; char sav = ums__input[eposd/8]; ums__input[eposd/8] = 0; stat = regcomp(& preg, "^" "[ \\t]*", REG_EXTENDED); stat = regexec(& preg, str, nmatch, pmatch, eflags); ums__input[eposd/8] = sav; regfree(& preg); found = !stat; if(found){ eposd = ums__pos + 8*pmatch[0].rm_eo;} } /* */ if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* < data> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 19){ level++; } /* < param> */ if (level >= 0 && found){ int stat; regex_t preg; size_t nmatch = 1; regmatch_t pmatch[1]; int eflags = 0; char *str = ums__input+ums__pos/8; char sav = ums__input[eposd/8]; ums__input[eposd/8] = 0; stat = regcomp(& preg, "^" "[0-9]+", REG_EXTENDED); stat = regexec(& preg, str, nmatch, pmatch, eflags); ums__input[eposd/8] = sav; regfree(& preg); found = !stat; if(found){ eposd = ums__pos + 8*pmatch[0].rm_eo;} } /* */ if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* < data> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 21){ level++; } /* < param> */ if (level >= 0 && found){ int stat; regex_t preg; size_t nmatch = 1; regmatch_t pmatch[1]; int eflags = 0; char *str = ums__input+ums__pos/8; char sav = ums__input[eposd/8]; ums__input[eposd/8] = 0; stat = regcomp(& preg, "^" "[ \\t]*", REG_EXTENDED); stat = regexec(& preg, str, nmatch, pmatch, eflags); ums__input[eposd/8] = sav; regfree(& preg); found = !stat; if(found){ eposd = ums__pos + 8*pmatch[0].rm_eo;} } /* */ if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* < value> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 23){ level++; } if (level >= 0 && found){ int len = strlen(")"); char *str = ums__input+ums__pos/8; found = !strncmp(str,")",len); eposd = ums__pos + len*8; } if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ if (level < 0){ break; } found2 = 1; break; } if (level >= 0){ level--; if (level < 0){ return found2; } if (found2==0){ break; } } } /* */ /* < zeroOrMore> */ { int pos1 = ums__pos; int i; int found2 = 0; if (level >= 0 || label == 24){ level++; } for(i=0; i < 3 ; i++){ /* < loopGroup> */ /* < data> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 26){ level++; } /* < param> */ if (level >= 0 && found){ int stat; regex_t preg; size_t nmatch = 1; regmatch_t pmatch[1]; int eflags = 0; char *str = ums__input+ums__pos/8; char sav = ums__input[eposd/8]; ums__input[eposd/8] = 0; stat = regcomp(& preg, "^" "[ \\t]+", REG_EXTENDED); stat = regexec(& preg, str, nmatch, pmatch, eflags); ums__input[eposd/8] = sav; regfree(& preg); found = !stat; if(found){ eposd = ums__pos + 8*pmatch[0].rm_eo;} } /* */ if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* < data> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 30){ level++; } /* < param> */ if (level >= 0 && found){ int stat; regex_t preg; size_t nmatch = 1; regmatch_t pmatch[1]; int eflags = 0; char *str = ums__input+ums__pos/8; char sav = ums__input[eposd/8]; ums__input[eposd/8] = 0; stat = regcomp(& preg, "^" "[0-9]+", REG_EXTENDED); stat = regexec(& preg, str, nmatch, pmatch, eflags); ums__input[eposd/8] = sav; regfree(& preg); found = !stat; if(found){ eposd = ums__pos + 8*pmatch[0].rm_eo;} } /* */ if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* */ if (level < 0){ break; } pos1 = ums__pos; found2 ++; } if (level >= 0){ level--; ums__pos = pos1; if (level < 0){ if (found2 < 1){ found2 = 0; } return found2; } if (found2 < 0){ break; } } } /* */ /* < choice> */ { int pos1 = ums__pos; int found2 = 0; if (level >= 0 || label == 32){ level++; } /* < choiceGroup> */ if (level >= 0 || label == 33){ level++; } while(found2 == 0){ /* < value> */ /* */ /* < data> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 36){ level++; } /* < param> */ if (level >= 0 && found){ int stat; regex_t preg; size_t nmatch = 1; regmatch_t pmatch[1]; int eflags = 0; char *str = ums__input+ums__pos/8; char sav = ums__input[eposd/8]; ums__input[eposd/8] = 0; stat = regcomp(& preg, "^" "[ \\t]+", REG_EXTENDED); stat = regexec(& preg, str, nmatch, pmatch, eflags); ums__input[eposd/8] = sav; regfree(& preg); found = !stat; if(found){ eposd = ums__pos + 8*pmatch[0].rm_eo;} } /* */ if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* < data> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 38){ level++; } /* < param> */ if (level >= 0 && found){ int stat; regex_t preg; size_t nmatch = 1; regmatch_t pmatch[1]; int eflags = 0; char *str = ums__input+ums__pos/8; char sav = ums__input[eposd/8]; ums__input[eposd/8] = 0; stat = regcomp(& preg, "^" "#", REG_EXTENDED); stat = regexec(& preg, str, nmatch, pmatch, eflags); ums__input[eposd/8] = sav; regfree(& preg); found = !stat; if(found){ eposd = ums__pos + 8*pmatch[0].rm_eo;} } /* */ if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ /* < data> */ { int found = 1; int eposd = epos1; if (level >= 0 || label == 41){ level++; } /* < param> */ if (level >= 0 && found){ int stat; regex_t preg; size_t nmatch = 1; regmatch_t pmatch[1]; int eflags = 0; char *str = ums__input+ums__pos/8; char sav = ums__input[eposd/8]; ums__input[eposd/8] = 0; stat = regcomp(& preg, "^" ".+", REG_EXTENDED); stat = regexec(& preg, str, nmatch, pmatch, eflags); ums__input[eposd/8] = sav; regfree(& preg); found = !stat; if(found){ eposd = ums__pos + 8*pmatch[0].rm_eo;} } /* */ if (level >= 0){ level--; ums__pos = eposd; if (level < 0){ if(found){ return 1; }else{ return 0; }} if (!found){ break; } } } /* */ if (level < 0){ break; } found2 = 1; break; } if (level >= 0){ level--; if (found2==0){ ums__pos = pos1; } if (level < 0){ return found2; } } /* */ /* < choiceGroup> */ if (level >= 0 || label == 43){ level++; } while(found2 == 0){ /* < value> */ /* */ if (level < 0){ break; } found2 = 1; break; } if (level >= 0){ level--; if (found2==0){ ums__pos = pos1; } if (level < 0){ return found2; } } /* */ if (level >= 0){ level--; if (level < 0){ return found2; } if (found2==0){ break; } } } /* */ /* */ if (level < 0){ break; } found1 = 1; break; } if (level >= 0){ level--; if (level < 0){ return found1; } if (found1==0){ break; } } } /* */ } die("ums:match() - internal error"); return 0; } /* */ /* // Definition of Decoder (mapping decoder) */ /* < oclng:decoderSub> */ int parse(char input[], int len){ ums__readReset(); ums__input = input; int epos1 = len; ums__pos = 0; /* < group> */ match(4, epos1); { int epos2 = ums__pos; ums__pos = ums__pos0; { /* < oclng:readerSub> */ /* < group> */ match(8, epos2); { int epos3 = ums__pos; ums__pos = ums__pos0; { /* < value> */ match(9, epos3); /* */ /* < data> */ match(10, epos3); /* < param> */ /* */ /* */ /* < data> */ match(13, epos3); /* < param> */ /* */ vect.name = ums__txtRead(ums__pos0, ums__pos); /* */ /* < value> */ match(15, epos3); /* */ /* < data> */ match(16, epos3); /* < param> */ /* */ /* */ /* < data> */ match(19, epos3); /* < param> */ /* */ vect.order = atoi(ums__txtRead(ums__pos0, ums__pos)); /* */ /* < data> */ match(21, epos3); /* < param> */ /* */ /* */ /* < value> */ match(23, epos3); /* */ } ums__pos = epos3; } /* */ /* < zeroOrMore> */ match(24, epos2); { int epos3 = ums__pos; ums__pos = ums__pos0; int i24, n = ums__found; for(i24=0; i24 < n; i24++ ){ /* < loopGroup> */ /* < data> */ match(26, epos3); /* < param> */ /* */ /* */ /* < data> */ match(30, epos3); /* < param> */ /* */ vect.value[i24] = atoi(ums__txtRead(ums__pos0, ums__pos)); /* */ /* */ } ums__pos = epos3; } /* */ /* < choice> */ match(32, epos2); { int epos3 = ums__pos; ums__pos = ums__pos0; if( 0 ){ ; } /* < choiceGroup> */ else if (match(33, epos3) != 0){ int epos4 = ums__pos; ums__pos = ums__pos0; { /* < value> */ hasComment = atoi("1"); /* */ /* < data> */ match(36, epos4); /* < param> */ /* */ /* */ /* < data> */ match(38, epos4); /* < param> */ /* */ /* */ /* < data> */ match(41, epos4); /* < param> */ /* */ comment = ums__txtRead(ums__pos0, ums__pos); /* */ } ums__pos = epos4; } /* */ /* < choiceGroup> */ else if (match(43, epos3) != 0){ int epos4 = ums__pos; ums__pos = ums__pos0; { /* < value> */ hasComment = atoi("0"); /* */ } ums__pos = epos4; } /* */ ums__pos = epos3; } /* */ userProgram(); /* */ } ums__pos = epos2; } /* */ return 0; } /* */