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