view Paper/src/WcImpl.cbc @ 10:7573c185aecf

add impl
author ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
date Tue, 25 Jan 2022 22:27:17 +0900
parents 38dfa4d8b0be
children
line wrap: on
line source

__code putString(struct WcImpl* wc, int line, __code next(...)){
  if (wc->strTable[line] != NULL){
    wcString* string = NEW(wcString);
    string->str = wc->strTable[line];
    goto countUp(string, next);
  } else {
    goto showResult(next);
  }
}

__code countUp(struct WcImpl* wc, wcString* string, __code next(...)) {
  printf("countUp「%s」\n", string->str);
  wc->lineNum = wc->lineNum + 1;
  int num = wc->lineNum;
  wc->wordNum = wc->wordNum + strlen(string->str);
  Gearef(context, Wc)->line = num;
  goto putString(num, next);
}

__code showResult(struct WcImpl* wc, __code next(...)) {
  printf("Number of Words is 「%d」\n", wc->wordNum);
  printf("EOF and finish codes\n");
  goto next(...);
}