cec26fcacfe00f33f4c70b976e6a798b53e5e5cf
[YACASL2.git] / test / unit / linetok / cmd.c
1 #include <stdio.h>
2 #include "assemble.h"
3 #include "cmem.h"
4 #include "cerr.h"
5 #include "word.h"
6
7 int main(){
8     int i, j;
9     char *testline[] = {
10         "IOTEST START\n",
11         "       OUT OBUF1,OLEN1\n",
12         "       OUT OBUF2,OLEN2 ;comment\n",
13         "       OUT OBUF1,OLEN1 \n",
14         "       OUT OBUF1,OLEN1 \n",
15         "       OUT OBUF2,OLEN2 \n",
16         "       OUT OBUF1, OLEN1 \n",
17         "BEGIN  LD      GR1, A\n",
18         "\n",
19         "       ;comment\n"
20     };
21
22     CMDLINE *testcl = malloc(sizeof(CMDLINE));
23     cerr_init();    /* エラーの初期化 */
24     for(i = 0; i < sizeof testline /sizeof testline[0]; i++) {
25         printf("%d: %s", i, testline[i]);
26         testcl = linetok(testline[i]);
27         if(testcl == NULL) {
28             puts("cl is NULL");
29         } else {
30             if(testcl->label != NULL){
31                 printf("cl->label: %s\n", testcl->label);
32             }
33             if(testcl->cmd != NULL){
34                 printf("cl->cmd: %s\n", testcl->cmd);
35                 printf("cl->opdc: %d\n", testcl->opd->opdc);
36                 for(j = 0; j < testcl->opd->opdc; j++) {
37                     printf("cl->opdv[%d]: %s\n", j, testcl->opd->opdv[j]);
38                 }
39             }
40         }
41         if(cerr->num != 0) {
42             printf("\terror - %d: %s\n", cerr->num, cerr->msg);
43         }
44         printf("\n");
45     }
46     freecerr();
47     return 0;
48 }