view Paper/src/WcImpl.cbc @ 47:49c1503c9176

...
author matac42 <matac@cr.ie.u-ryukyu.ac.jp>
date Mon, 29 Jan 2024 18:45:13 +0900
parents c8151a82f313
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(...);
}