1 /************************************************************************
4 * (c) Copyright 2009, $COMPANY_EN. Inc., $CITY_EN, $COUNTRY_EN
5 * (c) Copyright 2009, $COMPANY_CN. Inc., $CITY_CN, $COUNTRY_CN
6 ************************************************************************
11 * note:this file is designed for env variable expanssion.
14 ************************************************************************/
16 /************************************************************************
21 ************************************************************************/
33 /*******************************
34 *******************************
36 *******************************
37 *******************************/
38 //#define MODULE_NAME MODULE_CLASS_XXX
40 /* System include files */
49 /* Project module include files */
52 /* Private include files */
53 //#include <XXX_Private.h>
56 /*******************************
57 *******************************
58 * 2. Global Variables &
62 *******************************
63 *******************************/
66 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
67 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 0, 5, 0, 0, // 0
68 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1
69 /* ' ' ! " # $ % & ' ( ) * + , - . / */
70 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 2
71 /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
72 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, // 3
73 /* @ A B C D E F G H I J K L M N O */
74 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 4
75 /* P Q R S T U V W X Y Z [ \ ] ^ _ */
76 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 3, 3, 2, // 5
77 /* ` a b c d e f g h i j k l m n o */
78 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 6
79 /* p q r s t u v w x y z { | } ~ */
80 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 0, // 7
83 struct token_id
*pstTokenNameTbl
;
86 TOKEN_PROC_STATE
*gpstTokenStateTbl
;
88 char *gpszTokenStr
= NULL
;
92 SRC_FILE_DESC
*gpcurr_src_file
= NULL
;
101 #include "token/token.var"
103 //#include "token/quoted-str.var"
104 //#include "token/dollar.var"
105 //#include "token/cmd.var"
108 /*******************************
109 *******************************
110 * 3. Private Functions Implement
111 *******************************
112 *******************************/
116 /*******************************
117 *******************************
118 * 4. Public Functions Implement
119 *******************************
120 *******************************/
123 #define INIT_PRINTF //printf
127 #include "token/code.c"
130 #include "token/cmnt.c"
131 #include "token/quoted-str.c"
132 #include "token/dollar.c"
133 #include "token/cmd.c"
136 void token_ungetstr (char *str
, int len
, SRC_FILE_DESC
*pfile
)
141 for (i
=0; i
<len
; i
++)
148 ungetc(c
, pfile
->file
);
152 void token_ungetc (char c
, SRC_FILE_DESC
*pfile
)
157 ungetc(c
, pfile
->file
);
160 char token_getc (SRC_FILE_DESC
*pfile
)
162 register char c
=getc(pfile
->file
);
168 // chk if need a new blk.
169 // async read a new blk.
173 void get_token_word (SRC_FILE_DESC
*pfile
)
180 * if file content include NULL char, it should be ignored.
182 // if (pfile->bakchar)
184 // c = pfile->bakchar;
185 // pfile->bakchar = 0;
188 // c=token_getc(pfile->file);
190 pfile
->iTokenStrLen
= 0;
194 while (c
=token_getc(pfile
))
196 pfile
->lasttype
= pfile
->type
;
199 if (c
== EOF
) // { printf("EOF(%x)\n", c); exit(0); }
201 pfile
->type
= TYPE_EOF
;
207 cc
=token_getc(pfile
);
208 pfile
->type
= TYPE_WORD
;
212 pfile
->type
= map_tbl
[c
&0x7F];
213 // printf("c(%x) = %c(%d, 0x%08x)\n", (unsigned int)c, c, pfile->type, (unsigned int)pfile->lasttype);
216 if (pfile
->lasttype
== 0)
218 pfile
->aTokenStrBuff
[0] = c
;
219 pfile
->iTokenStrLen
= 1;
224 if (pfile
->type
== pfile
->lasttype
)
226 pfile
->aTokenStrBuff
[pfile
->iTokenStrLen
] = c
;
227 pfile
->iTokenStrLen
++;
231 /* ungetc(), the different type char. */
232 token_ungetc(c
, pfile
);
233 pfile
->type
= pfile
->lasttype
;
239 pfile
->aTokenStrBuff
[pfile
->iTokenStrLen
] = 0;
241 // gpszTokenStr = gpcurr_src_file->aTokenStrBuff;
244 int before_ret_proc (SRC_FILE_DESC
*psrcfile
, TOKEN_PROC_STATE
*pstTokenState
, int ret
)
249 * switching to new state, then invoke proc func,
250 * keeps proc func invoked in the same state.
252 if (pstTokenState
->paired_state
)
254 STATE_SWITCH(psrcfile
, pstTokenState
->paired_state
);
255 printf("switch to strStateName = %s\n", psrcfile
->pstCurrTokenState
->pstStateInfo
->strStateName
);
256 pstTokenState
= psrcfile
->pstCurrTokenState
;
259 if (pstTokenState
->paired_token
!= 0 && pstTokenState
->paired_token
== ret
)
261 tmp
= pstTokenState
->pfnPairTokenProc(
264 &psrcfile
->aTokenStrBuff
[psrcfile
->iPrevIdx
],
265 psrcfile
->iTokenStrLen
- psrcfile
->iPrevIdx
,
268 /* switching back to latest state */
269 STATE_RECOVERY(psrcfile
);
270 printf("recovery to strStateName = %s\n", psrcfile
->pstCurrTokenState
->pstStateInfo
->strStateName
);
272 psrcfile
->pstCurrTokenState
->state_token_str
= 0;
273 pstTokenState
->pfnPairTokenProc
= NULL
;
277 tmp
= pstTokenState
->pfnTokenProc(
280 &psrcfile
->aTokenStrBuff
[psrcfile
->iPrevIdx
],
281 psrcfile
->iTokenStrLen
- psrcfile
->iPrevIdx
,
283 pstTokenState
->pfnTokenProc
= NULL
;
284 // printf("token = %d;\n", ret);
297 #define paired_token_matching(str, len, token) strncmp(str, token, len);
299 int token_read (SRC_FILE_DESC
*psrcfile
)
303 TOKEN_PROC_STATE
*pstTokenState
= psrcfile
->pstCurrTokenState
;
305 // printf("%s: %s()\n", __FILE__, __FUNCTION__);
309 free_string(&strbuff
);
313 /* single step for token debugging. */
317 // printf("iPrevIdx = %d; iTokenStrLen = %d; recent_token = %d; nl_cnt = %d;\n",
318 // psrcfile->iPrevIdx,
319 // psrcfile->iTokenStrLen,
320 // pstTokenState->recent_token,
321 // pstTokenState->nl_cnt);
324 * @ token string buffer getting.
325 * # no token to be returned (recent_token==0).
326 * # no bufferd string to be analyzed (PrevIdx == TokenStrLen).
327 * it trig new buffer appending.
329 if (psrcfile
->iPrevIdx
>= psrcfile
->iTokenStrLen
&&
330 pstTokenState
->recent_token
== 0 &&
331 pstTokenState
->nl_cnt
== 0)
332 get_token_word(psrcfile
);
335 printf("aTokenStrBuff{%d} = \"%s\"\n",
336 psrcfile
->iTokenStrLen
- psrcfile
->iPrevIdx
,
337 &psrcfile
->aTokenStrBuff
[psrcfile
->iPrevIdx
]);
340 //strcpy(str_buff, &psrcfile->aTokenStrBuff[psrcfile->iPrevIdx]);
341 //str_idx = strlen(str_buff);
342 append_string( &strbuff
,
343 &psrcfile
->aTokenStrBuff
[psrcfile
->iPrevIdx
],
344 psrcfile
->iTokenStrLen
- psrcfile
->iPrevIdx
);
346 psrcfile
->iTokenStrLen
= 0;
347 if (psrcfile
->type
== TYPE_EOF
)
355 * if PrevIdx < TokenStrLen, it means token string buffer need to be analyzed.
356 * if recent_token is not, it means the latest token have not been returned,
357 * it should not analyze in current time.
359 if ((psrcfile
->iPrevIdx
< psrcfile
->iTokenStrLen
&&
360 pstTokenState
->recent_token
== 0 &&
361 pstTokenState
->nl_cnt
== 0) ||
362 psrcfile
->type
== TYPE_EOF
)
365 * it should be reset to 0 before new analyzing.
370 if (psrcfile
->pstCurrTokenState
->state_token_str
)
372 ret
= paired_token_matching(
373 &psrcfile
->aTokenStrBuff
[psrcfile
->iPrevIdx
],
374 strlen(psrcfile
->pstCurrTokenState
->state_token_str
),
375 psrcfile
->pstCurrTokenState
->state_token_str
381 ret
= psrcfile
->pstCurrTokenState
->paired_token
;
382 pstTokenState
->token_len
= strlen(psrcfile
->pstCurrTokenState
->state_token_str
);
386 // printf("paired token(%d, %d): %s\n", ret, pstTokenState->token_len, psrcfile->pstCurrTokenState->state_token_str);
392 ret
= psrcfile
->pstStateInfo
->astTokenTypeTbl
[psrcfile
->type
].pfnTokenStrProc(
393 &psrcfile
->aTokenStrBuff
[psrcfile
->iPrevIdx
],
395 psrcfile
->pstCurrTokenState
);
400 printf("iPrevIdx = %d; iTokenStrLen = %d; token_len = %d; recent_token = %d; ret = %d\n",
402 psrcfile
->iTokenStrLen
,
403 pstTokenState
->token_len
,
404 pstTokenState
->recent_token
,
408 // psrcfile->iPrevIdx = 0;
409 // psrcfile->iTokenStrLen = 0;
410 pstTokenState
->recent_token
= 0;
415 // printf("return val = %d, %d; (%s)\n", ret, psrcfile->pstCurrTokenState->token_len, &psrcfile->aTokenStrBuff[psrcfile->iPrevIdx]);
418 * @ resualt token outputting.
419 * when analyzing, there are two kinds of punct string:
420 * # <PUNCT>...always return ret=token.
421 * # <WORD><PUNCT>...always return ret=T_WORD token, and restore PUNCT token
423 * when no analyzing work, return recent_token.
424 * when no analyzing work, no recent_token, return 0.
426 if (psrcfile
->type
== TYPE_EOF
)
428 printf("TYPE_EOF\n");
431 else if (psrcfile
->type
== TYPE_SPACE
)
434 * for space string, just store it in buffer,
435 * it will be accessed when need in next token.
437 psrcfile
->iPrevIdx
+= pstTokenState
->token_len
;
442 if (pstTokenState
->nl_cnt
> 0)
444 pstTokenState
->nl_cnt
--;
445 pstTokenState
->recent_token
= T_EOL
;
446 pstTokenState
->token_len
= 1;
447 psrcfile
->iPrevIdx
+= pstTokenState
->token_len
;
452 // printf("xxxxxxxxxxxxxxxx %d %d\n", psrcfile->iPrevIdx, pstTokenState->token_len);
453 ret
= (ret
== 0) ? pstTokenState
->recent_token
: ret
;
454 psrcfile
->iPrevIdx
+= pstTokenState
->token_len
;
455 pstTokenState
->recent_token
= 0;
466 psrcfile
->iPrevIdx
+= pstTokenState
->token_len
;
467 // printf("a psrcfile->iPrevIdx = %d, %d;\n", psrcfile->iPrevIdx, pstTokenState->token_len);
471 /* invoke proc func */
472 if ((pstTokenState
->recent_token
== 0 && pstTokenState
->pfnTokenProc
!= NULL
)
473 || pstTokenState
->pfnPairTokenProc
!= NULL
)
474 ret
= before_ret_proc(psrcfile
, pstTokenState
, ret
);
476 tmp
= pstTokenState
->token_len
;
477 pstTokenState
= psrcfile
->pstCurrTokenState
;
478 pstTokenState
->token_len
= tmp
;
481 * str_idx will be used when T_WORD token return,
482 * do not reset it here, and reset it later.
485 psrcfile
->iPrevIdx
+= (ret
== T_WORD
) ? strbuff
.text_size
: pstTokenState
->token_len
;
486 // if (ret != T_WORD && ret != T_SKIP)
488 // printf("############################################ str_idx = 0;\n");
494 // psrcfile->iPrevIdx += pstTokenState->token_len;
495 // printf("psrcfile->iPrevIdx = %d, %d;\n", psrcfile->iPrevIdx, pstTokenState->token_len);
500 * if token combined out of this function,
501 * it should process iTokenIdNum in code.
503 psrcfile
->pstCurrTokenState
->iTokenIdNum
++;
506 else if (pstTokenState
->recent_token
!= 0)
508 ret
= pstTokenState
->recent_token
;
509 pstTokenState
->recent_token
= 0;
510 // psrcfile->iPrevIdx += pstTokenState->token_len;
514 psrcfile
->iPrevIdx
+= pstTokenState
->token_len
;
515 pstTokenState
->token_len
= 0;
518 pstTokenState
->token_len
= 0;
520 if (pstTokenState
->pfnTokenProc
!= NULL
|| pstTokenState
->pfnPairTokenProc
!= NULL
)
521 ret
= before_ret_proc(psrcfile
, pstTokenState
, ret
);
523 tmp
= pstTokenState
->token_len
;
524 pstTokenState
= psrcfile
->pstCurrTokenState
;
525 // printf("pstStateInfo->strStateName = %s;\n", pstTokenState->pstStateInfo->strStateName);
526 pstTokenState
->token_len
= tmp
;
528 psrcfile
->iPrevIdx
+= pstTokenState
->token_len
;
529 // if (ret != T_WORD && ret != T_SKIP)
534 psrcfile
->iPrevIdx
+= pstTokenState
->token_len
;
538 psrcfile
->pstCurrTokenState
->iTokenIdNum
++;
545 printf("return zero.\n");
546 /* if ret & recent_token are all zero, it should return 0 */
550 extern int on_token_proc (int ret
);
554 * TBD: token item sorting.
555 * "+=" should be putted before "+", that program can matching first for long string word.
556 * or, use idx-tbl map to a proc tbl, and point to corresponding TokenTbl item at last.
557 * or, use sorted str-tbl, first chars are created in a idx-tbl.
559 * @ get token name string tbl, and sorting:
567 * @ create a first level idx-tbl.
575 [06] [ ,e,13], ==> 'enum'
579 [0a] [ ,r,14], ==> 'for'
581 [0c] [ ,e,15], ==> 'foreach'
582 [0d] [ ,i,16] ==> 'fix'
583 [0e] [ ,e,15]xxxxxxxxxxxxxxxx
584 [0f] [ ,s,17], ==> 'struct'
585 [10] [ ,t,18], ==> 'typedef'
586 [11] [ ,u,19], ==> 'unioin'
589 [13] [ADDR], point to 'enum' item struct.
591 [15] [ADDR], 'foreach'
593 [17] [ADDR], 'struct'
594 [18] [ADDR], 'typedef'
596 * @ [char,lastchar,idx]
597 * char, current matching char. if equal to zero, it means matching.
598 * lastchar, if it is different in next idx info, that means
599 * idx, idx value in tbl for next char. if matching, it point to a idx with token item addr.
601 * # ergodic every idx item in loop, util lastchar is different.
602 * # matching 'char' and given string,
603 * # invoke func, and processing matched idx item in embedded by algrithm of XXXXXXX.
604 * @ f(m,n,l)=min(m,l)*n,
605 * min(m,l), string compare times
607 * eg: m=5,n=20, it will running one handrod time for loop.
608 * @ by using idx-tbl, it matching first char by list, and so on the rest.
609 * f(m,n,l)=n+min(m,l)
610 * @ if the first level idx-tbl store in a ascii idx-tbl.
611 * f(m,n,l)=1+min(m,l)
613 void * init_idx_tbl (SRC_FILE_DESC
*pfiledesc
)
616 * token string sorting
617 * get row count and max word length.
621 * create 128 unit for first char indexing.
622 * for some state, there are few token defined,
623 * it does not need first-char-indexding.
627 * alloc memory accroding row count and max word length.
628 * create index info for token strings.
633 void * str_matching_by_idx_tbl (char *str
, void *pvIdxTbl
, struct token_id
*pstTokenIdTbl
, short *ptoken_len_tbl
)
637 void init_token_len_tbl (const struct token_id
*ptoken_tbl
, unsigned short *plen_tbl
, int size
)
641 if (ptoken_tbl
== NULL
) return;
643 for (i
=0; i
<MAX_TOKEN_ID_TBL_SIZE
; i
++)
645 if (ptoken_tbl
[i
].tokenstr
== NULL
&&
646 ptoken_tbl
[i
].token
== 0 &&
647 ptoken_tbl
[i
].flags
== 0 &&
648 ptoken_tbl
[i
].proc
== NULL
)
651 if (ptoken_tbl
[i
].name
!= NULL
)
653 if (ptoken_tbl
[i
].chars
[3] != 0)
654 plen_tbl
[i
] = strlen(ptoken_tbl
[i
].name
);
656 plen_tbl
[i
] = strlen((char *)&ptoken_tbl
[i
].name
);
659 if (ptoken_tbl
[i
].chars
[3] != 0)
660 INIT_PRINTF("%s(%d)\n", ptoken_tbl
[i
].name
, plen_tbl
[i
]);
662 INIT_PRINTF("%s(%d)\n", (char *)&(ptoken_tbl
[i
].name
), plen_tbl
[i
]);
666 void get_strlen_tbl (TOKEN_PROC_STATE_INFO
*pstStateInfo
)
670 const struct token_id
*ptoken_tbl
;
673 if (pstStateInfo
->strStateName
== NULL
) return;
674 INIT_PRINTF("strStateName = %s;\n", pstStateInfo
->strStateName
);
676 ptoken_tbl
= pstStateInfo
->astTokenTypeTbl
[TYPE_WORD
].pstTokenTbl
;
677 INIT_PRINTF("[TYPE_WORD]: 0x%08x\n", (unsigned int)ptoken_tbl
);
678 if (ptoken_tbl
!= NULL
)
680 size
= pstStateInfo
->astTokenTypeTbl
[TYPE_WORD
].iTblSize
;
681 plen_tbl
= (short *) malloc(size
*sizeof(short));
682 init_token_len_tbl(ptoken_tbl
, plen_tbl
, size
);
683 pstStateInfo
->api16TokenNameLen
[TYPE_WORD
] = plen_tbl
;
686 INIT_PRINTF("[TYPE_PUNCT]:\n");
687 ptoken_tbl
= pstStateInfo
->astTokenTypeTbl
[TYPE_PUNCT
].pstTokenTbl
;
688 if (ptoken_tbl
!= NULL
)
690 size
= pstStateInfo
->astTokenTypeTbl
[TYPE_PUNCT
].iTblSize
;
691 plen_tbl
= (short *) malloc(size
*sizeof(short));
692 init_token_len_tbl(ptoken_tbl
, plen_tbl
, size
);
693 pstStateInfo
->api16TokenNameLen
[TYPE_PUNCT
] = plen_tbl
;
696 INIT_PRINTF("[TYPE_PFX]:\n");
697 ptoken_tbl
= pstStateInfo
->astTokenTypeTbl
[TYPE_PFX
].pstTokenTbl
;
698 if (ptoken_tbl
!= NULL
)
700 size
= pstStateInfo
->astTokenTypeTbl
[TYPE_PFX
].iTblSize
;
701 plen_tbl
= (short *) malloc(size
*sizeof(short));
702 init_token_len_tbl(ptoken_tbl
, plen_tbl
, size
);
703 pstStateInfo
->api16TokenNameLen
[TYPE_PFX
] = plen_tbl
;
706 INIT_PRINTF("[TYPE_PAIR]:\n");
707 ptoken_tbl
= pstStateInfo
->astTokenTypeTbl
[TYPE_PAIR
].pstTokenTbl
;
708 if (ptoken_tbl
!= NULL
)
710 size
= pstStateInfo
->astTokenTypeTbl
[TYPE_PAIR
].iTblSize
;
711 plen_tbl
= (short *) malloc(size
*sizeof(short));
712 init_token_len_tbl(ptoken_tbl
, plen_tbl
, size
);
713 pstStateInfo
->api16TokenNameLen
[TYPE_PAIR
] = plen_tbl
;
714 for (i
=0; i
<size
; i
++)
720 INIT_PRINTF("[Micro]:\n");
721 //ptoken_tbl = pstStateInfo->astTokenTypeTbl[TYPE_PAIR].pstTokenTbl;
722 //size = pstStateInfo->astTokenTypeTbl[TYPE_PAIR].iTblSize;
723 plen_tbl
= (short *) malloc(size
*sizeof(short));
724 if (ptoken_tbl
!= NULL
)
726 init_token_len_tbl(macro_array
, au16MacroTokenLen
, ARRAY_SIZE(macro_array
));
727 //pstStateInfo->api16TokenNameLen[TYPE_PAIR] = plen_tbl;
731 TOKEN_PROC_STATE
*state_alloc_init (SRC_FILE_DESC
*pfiledesc
, int iState
)
733 TOKEN_PROC_STATE
*pstTokenState
= (TOKEN_PROC_STATE
*) malloc(sizeof(TOKEN_PROC_STATE
));
734 if (pstTokenState
== NULL
) return NULL
;
736 INIT_PRINTF("state_alloc_init(%d);\n", iState
);
737 memset(pstTokenState
, 0x00, sizeof(TOKEN_PROC_STATE
));
739 pfiledesc
->pstStateInfo
= &pfiledesc
->pstStateInfoTbl
[iState
];
740 pstTokenState
->pstStateInfo
= pfiledesc
->pstStateInfo
;
741 pstTokenState
->iStateId
= iState
;
743 /* duplicate var-info to new state. */
744 if (pfiledesc
->pstCurrTokenState
)
746 pstTokenState
->paired_token
= pfiledesc
->pstCurrTokenState
->paired_token
;
747 pstTokenState
->state_token_str
= pfiledesc
->pstCurrTokenState
->state_token_str
;
749 pstTokenState
->token_str
= pfiledesc
->pstCurrTokenState
->token_str
;
750 pstTokenState
->token_len
= pfiledesc
->pstCurrTokenState
->token_len
;
751 pfiledesc
->pstCurrTokenState
->paired_state
= 0;
753 if (pfiledesc
->pstCurrTokenState
->pfnPairTokenProc
!= NULL
)
754 pstTokenState
->pfnPairTokenProc
= pfiledesc
->pstCurrTokenState
->pfnPairTokenProc
;
755 pfiledesc
->pstCurrTokenState
->pfnPairTokenProc
= NULL
;
757 if (pfiledesc
->pstCurrTokenState
->pfnTokenProc
!= NULL
)
758 pstTokenState
->pfnTokenProc
= pfiledesc
->pstCurrTokenState
->pfnTokenProc
;
759 pfiledesc
->pstCurrTokenState
->pfnTokenProc
= NULL
;
761 return pstTokenState
;
765 * fdesc: open file, and init SRC_FILE_DESC structure.
767 SRC_FILE_DESC
*src_file_init (SRC_FILE_DESC
*file
, char *filename
, TOKEN_PROC_STATE_INFO astTokenStateTbl
[], int num
)
769 if (filename
!= NULL
)
771 file
->filename
= filename
;
772 file
->file
= fopen(filename
, "r");
777 file
->pstStateInfoTbl
= astTokenStateTbl
;
778 file
->iStateInfoNum
= num
;
779 file
->pstCurrTokenState
= state_alloc_init(file
, STATE_CODE
);
781 //file->pfnMTokenStrProc = NULL;
782 file
->pstMTokenTbl
= macro_array
;
783 file
->pu16MTokenNameLen
= au16MacroTokenLen
;
785 /* init len-tbl .api16TokenNameLen in TOKEN_PROC_STATE */
786 for (int i
; i
<sizeof(gastInnerTokenStateTbl
)/sizeof(gastInnerTokenStateTbl
[0]); i
++)
788 INIT_PRINTF("########################################\n");
789 get_strlen_tbl(&file
->pstStateInfoTbl
[i
]);
797 /* do not need to init buffer */
802 file
->iTokenStrLen
= 0;
806 file
->pStkBuff
= malloc(MAX_STATE_NUM
* sizeof(void *));
807 QStackIF_InitStack(&file
->stStateStk
, file
->pStkBuff
, MAX_STATE_NUM
* sizeof(void *));
808 QStackIF_SetDataOprType(&file
->stStateStk
, OPR_UINT32
);
811 file
->pStkBuff
= malloc(MAX_TOKEN_NUM
* 2 * sizeof(void *));
812 QStackIF_InitQueue(&file
->stTokenQ
, file
->pStkBuff
, MAX_TOKEN_NUM
* 2 * sizeof(void *));
813 QStackIF_SetDataOprType(&file
->stTokenQ
, OPR_UINT32
);
818 void src_file_release (SRC_FILE_DESC
*file
)
823 int load_token_def_file (char *token_def_file
)
827 SRC_FILE_DESC src_code_file
;
829 printf("open file: %s\n", token_def_file
);
831 gpcurr_src_file
= src_file_init (&src_code_file
,
833 gastInnerTokenStateTbl
,
834 ARRAY_SIZE(gastInnerTokenStateTbl
));
836 while (token
=token_read(gpcurr_src_file
))
838 // printf("Token = %d\n", token);
840 on_token_proc(token
);
843 printf("token = %d\n", token
);
850 /*******************************
851 *******************************
853 *******************************
854 *******************************/