4 * @ use xxx_string() serial of functions, instead of buff opr. put caching buff
5 * pointer in state structure.
6 * @ lookup first token in comment string for MACRO.
7 * + define MACRO process (#define, #if, #include, #pragma)
8 * @ state-doc: c89-cmnt/ext-cmnt/dquoted-str/here-doc/help-doc/macro-code
9 * @ put global env into a struct.
12 * # $'', $ flag, and using.
14 * # ${}, $ flag, envar state.
15 * # foo () {}, func-flag, {} paired-token,
19 * @ readuntil-doc: c99-cmnt/sh-cmnt/backquoted-str/quoted-str/func-code
23 * bracket & quote & string.
24 * @ //, #, comment prefix (readuntil).
25 * # use caching buffer.
27 * @ '', ``, $'', $``, get string/code from pair-char to pair-char.
29 * @ "", $"", get string in string-state.
30 * @ (), $(), <(), >(), foo(){} code-block.
31 * @ $[], $(()), expr string.
32 * @ $XXX, ${}, parsing env-var format in envar-state.
36 /* TBD: use CACHING_STR */
45 char *token_str
= NULL
;
46 TOKEN_ID_PROC pfn_token_proc
= NULL
;
48 #define BYTE_MASK(n) ((1<<((n)<<3)) - 1)
54 char mask_char
= '\\';
58 char endstr
[MAX_RSVWD_LEN
];
61 extern void token_ungetc (char c
, SRC_FILE_DESC
*pfile
);
63 char read_getc (SRC_FILE_DESC
*pfile
)
65 extern char token_getc (SRC_FILE_DESC
*pfile
);
69 if ((pfile
->iTokenStrLen
- pfile
->iPrevIdx
) > 0)
71 c
= pfile
->aTokenStrBuff
[pfile
->iPrevIdx
];
75 c
= token_getc(pfile
);
80 void read_ungetc (char c
, SRC_FILE_DESC
*pfile
)
82 if (pfile
->iPrevIdx
> 0)
85 pfile
->aTokenStrBuff
[pfile
->iPrevIdx
] = c
;
88 token_ungetc(c
, pfile
);
91 int read_token_str (SRC_FILE_DESC
*pfile
)
97 * \retval: 0, in normal.
100 int readuntil (SRC_FILE_DESC
*pfile
)
105 while (str_idx
< sizeof(str_buff
)-1)
107 c
= read_getc(pfile
);
108 // printf("c=%c(%x)(%x)\n", c, c, endstr[0]);
109 // ignore NULL char in txt src file.
112 else if (c
== mask_char
)
114 c
= read_getc(pfile
);
116 else if (c
== pfx_char
)
120 else if (c
== pair_begin
)
124 else if (c
== pair_end
)
138 else if (endstr
[0] == 0)
140 read_ungetc(c
, pfile
);
143 else if (c
== endstr
[0])
147 while (i
< endstr_len
&& (c
=read_getc(pfile
)) == endstr
[i
]) i
++;
151 read_ungetc(c
, pfile
);
152 while (--i
) read_ungetc(endstr
[i
], pfile
);
154 // memcpy(&str_buff[str_idx], endstr, i);
156 // str_buff[str_idx] = 0;
162 str_buff
[str_idx
] = c
;
164 // str_buff[str_idx] = 0;
166 str_buff
[str_idx
] = 0;
167 if (str_idx
== sizeof(str_buff
)-1)
174 * c99 comment string proc.
176 int on_c99_cmnt_proc (int evt
, int token
, register const char *str
, register unsigned int len
, SRC_FILE_DESC
*psrcfile
)
178 printf("################################################ c99 comment\n");
188 /* TBD: use xxx_string() function to store txt. */
189 /* ignore overlimited comment string. */
190 while (readuntil(gpcurr_src_file
) == -1) str_idx
= 0;
191 // printf("str_idx = %d\n", str_idx);
199 * sh comment string proc.
201 int on_sh_cmnt_proc (int evt
, int token
, register const char *str
, register unsigned int len
, SRC_FILE_DESC
*psrcfile
)
206 int Macro_TokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
);
208 printf("################################################ sh comment\n");
215 c
= read_getc(psrcfile
);
216 if (c
== ' ' || c
== '\t')
221 str_buff
[str_idx
] = c
;
224 str_buff
[str_idx
] = 0;
226 ret
= Macro_TokenProc(str_buff
, str_idx
, gpcurr_src_file
->pstCurrTokenState
);
229 * no preproc cmd matching, it's a sh-cmnt.
230 * otherwize, return token.
243 /* ignore overlimited comment string. */
244 while (readuntil(gpcurr_src_file
) == -1) str_idx
= 0;
250 char trans_char_tbl
[128] = {
251 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
252 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0
253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1
254 /* ' ' ! " # $ % & ' ( ) * + , - . / */
255 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2
256 /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
257 -16,-17,-18, -19,-20, -21,-22, -23,-24, -25,0, 0, 0, 0, 0, 0, // 3
258 /* @ A B C D E F G H I J K L M N O */
259 0, -26,-27, -28,-29, -30,-31, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 4
260 /* P Q R S T U V W X Y Z [ \ ] ^ _ */
261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, // 5
262 /* ` a b c d e f g h i j k l m n o */
263 0, -26,-27, -28,-29, -30,'\f', 0, 0, 0, 0, 0, 0, 0, '\n', 0, // 6
264 /* p q r s t u v w x y z { | } ~ */
265 0, 0, '\r', 0, '\t', 0, '\v', 0, -127, 0, 0, 0, 0, 0, 0, 0, // 7
268 int str2hex (char *str
, int iidx
, int oidx
)
271 unsigned long long val
= 0;
273 char *pbuff
= &str
[iidx
];
279 * max hex string len is 32, it's a 128bit hex value string.
283 c
= trans_char_tbl
[pbuff
[i
]>>1];
284 if (c
< 0 || c
== '\f')
286 tmp
[i
] = ((c
<-15) ? (c
+16) : 0x0f);
294 for (; i
>=0; i
--) val
+= tmp
[i
]<<(chars
- i
);
298 for (i
=0; i
<chars
>>2; i
++)
300 pbuff
[i
] = (char)(val
>>i
);
306 int translate_char (char *str
, int len
)
317 for (i
=0; i
<len
; i
++)
324 c
= trans_char_tbl
[c
&0x7f];
325 str
[j
] = (c
> 0) ? c
: str
[i
];
329 c
= str2hex(str
, i
, j
);
330 j
+= (int)((c
+1)>>1);
348 int on_quote (int evt
, int token
, register const char *str
, register unsigned int len
, SRC_FILE_DESC
*psrcfile
)
350 printf("################################################ single quote\n");
360 /* ignore overlimited comment string. */
361 while (readuntil(gpcurr_src_file
) == -1) str_idx
= 0;
363 /* TBD: with $ flag, translate \X to corresponding char. */
364 if (CHK_STATE_FLAG(psrcfile
->pstCurrTokenState
, TF_DOLLAR
))
366 //CLR_STATE_FLAG(psrcfile->pstCurrTokenState, TF_DOLLAR);
367 str_idx
= translate_char(str_buff
, str_idx
);
368 STATE_RECOVERY(psrcfile
);
377 int on_bquote (int evt
, int token
, register const char *str
, register unsigned int len
, SRC_FILE_DESC
*psrcfile
)
379 printf("################################################ back quote\n");
388 /* ignore overlimited comment string. */
389 while (readuntil(gpcurr_src_file
) == -1) str_idx
= 0;
391 return T_WORD_BACK_QUOTE
;
394 int on_ext_cmnt (int evt
, int token
, register const char *str
, register unsigned int len
, SRC_FILE_DESC
*psrcfile
)
396 printf("################################################ ext comment\n");
398 if (evt
== EVT_ON_ENTER
)
403 else if (evt
== EVT_ON_EXIT
)
405 // do cmnt proc and return token.
410 int on_c89_cmnt (int evt
, int token
, register const char *str
, register unsigned int len
, SRC_FILE_DESC
*psrcfile
)
412 printf("a ################################################ c89 comment\n");
414 if (evt
== EVT_ON_ENTER
)
417 strcpy(str_buff
, "/*");
421 else if (evt
== EVT_ON_EXIT
)
424 // do cmnt proc and return token.
425 strcat(str_buff
, "*/");
430 ////////////////////////////////////
443 /* TBD: use xxx_string() function to store txt. */
444 /* ignore overlimited comment string. */
445 while (readuntil(gpcurr_src_file
) == -1) str_idx
= 0;
446 strcat(str_buff
, "*/");
447 // printf("str_idx = %d\n", str_idx);
454 int on_dquote (int evt
, int token
, register const char *str
, register unsigned int len
, SRC_FILE_DESC
*psrcfile
)
456 printf("################################################ dual quote\n");
466 * code-block, sub-script. stdout is main-script's stdout.
468 * code-block, sub-script. stdout is cmd-line buffer.
470 int on_cb_bracket1 (int evt
, int token
, register const char *str
, register unsigned int len
, SRC_FILE_DESC
*psrcfile
)
472 printf("################################################ bracket1 ()\n");
476 /* func param list */
481 int on_bracket2 (int evt
, int token
, register const char *str
, register unsigned int len
, SRC_FILE_DESC
*psrcfile
)
483 printf("################################################ bracket2 (())\n");
485 if (evt
== EVT_ON_ENTER
)
487 if (CHK_STATE_FLAG(psrcfile
->pstCurrTokenState
, TF_DOLLAR
))
489 STATE_RECOVERY(psrcfile
);
490 STATE_SWITCH(psrcfile
, STATE_EXPR
);
494 else if (evt
== EVT_ON_EXIT
)
496 if (CHK_STATE_FLAG(psrcfile
->pstCurrTokenState
, TF_DOLLAR
))
498 STATE_RECOVERY(psrcfile
);
506 int on_dbracket1 (int evt
, int token
, register const char *str
, register unsigned int len
, SRC_FILE_DESC
*psrcfile
)
508 printf("################################################ dbracket1 [[]]\n");
510 if (evt
== EVT_ON_ENTER
)
512 if (CHK_STATE_FLAG(psrcfile
->pstCurrTokenState
, TF_DOLLAR
))
514 STATE_RECOVERY(psrcfile
);
515 STATE_SWITCH(psrcfile
, STATE_EXPR
);
519 else if (evt
== EVT_ON_EXIT
)
521 if (STATE_CHK(psrcfile
, STATE_EXPR
))
523 STATE_RECOVERY(psrcfile
);
539 char *state_token_str
= NULL
;
540 TOKEN_ID_PROC pfn_pair_token_proc
= NULL
;
545 * @ use three func to process word/pair/other token.
547 int id_str_matching (char *str
, int str_len
, const struct token_id
*pstTokenIdTbl
, short *ptoken_len_tbl
)
553 int str_idx_bak
= str_idx
;
555 if (!pstTokenIdTbl
) return 0;
557 // printf("%s: %s(%s)(%d)\n", __FILE__, __FUNCTION__, str, str_len);
558 // printf("pstTokenIdTbl = 0x%08x\n", pstTokenIdTbl);
559 // printf("ptoken_len_tbl = 0x%08x\n", ptoken_len_tbl);
560 // printf("len = 0x%08x\n", len);
562 for (k
=0; len
>0; k
++)
564 plentbl
= ptoken_len_tbl
;
565 // printf("str=%s(%d)\n", str, k);
566 for (i
=0; i
<MAX_TOKEN_ID_TBL_SIZE
; i
++)
568 // printf("XXXXXXXXXXXXXXXXXXXXXXXXXX\n");
569 if (pstTokenIdTbl
[i
].name
== NULL
&&
570 pstTokenIdTbl
[i
].tokenstr
== NULL
&&
571 pstTokenIdTbl
[i
].token
== 0 &&
572 pstTokenIdTbl
[i
].flags
== 0 &&
573 pstTokenIdTbl
[i
].proc
== NULL
)
575 // printf("pstTokenIdTbl[%d].name = %s(0x%08x)(%s)\n", i, "token", pstTokenIdTbl[i].name, pstTokenIdTbl[i].tokenstr);
577 register int token_id_len
= *plentbl
;
580 if (len
< token_id_len
) continue;
582 /* TBD: normally, this addr area 'chars[3]' should not be used for user accessing. */
583 pstr
= (pstTokenIdTbl
[i
].chars
[3]) ? pstTokenIdTbl
[i
].name
: (char *)&pstTokenIdTbl
[i
].name
;
584 // printf("@%d.[%s]: %s(%d)(%d)\n", i, pstTokenIdTbl[i].tokenstr, pstr, token_id_len, pstTokenIdTbl[i].token);
586 for (j
=0; j
<token_id_len
; j
++)
588 if (pstr
[j
] != str
[j
])
591 if (j
== token_id_len
)
593 // printf("@%d.[%s]: %s(%d)(%d)[%s]\n", i, pstTokenIdTbl[i].tokenstr, pstr, token_id_len, pstTokenIdTbl[i].token, str);
595 if (pstr
[token_id_len
] != 0)
597 state_token_str
= &pstr
[token_id_len
];
598 pfn_pair_token_proc
= pstTokenIdTbl
[i
].proc
;
601 pfn_token_proc
= (TOKEN_ID_PROC
)pstTokenIdTbl
[i
].proc
;
602 token_len
= token_id_len
;
604 token_state
= pstTokenIdTbl
[i
].state
;
607 recent_token
= pstTokenIdTbl
[i
].token
;
611 return pstTokenIdTbl
[i
].token
;
613 else if (pstr
[token_id_len
])
615 for (h
=0,j
=token_id_len
; j
<(token_id_len
<<1); h
++,j
++)
617 if (pstr
[j
] != str
[h
])
620 if (j
== (token_id_len
<<1))
622 // printf("&%d.[%s]: %s(%d)(%d)\n", i, pstTokenIdTbl[i].tokenstr, &pstr[token_id_len], token_id_len, pstTokenIdTbl[i].token+1);
624 pfn_token_proc
= (TOKEN_ID_PROC
)pstTokenIdTbl
[i
].proc
;
625 token_len
= token_id_len
;
626 token_str
= &pstr
[token_id_len
];
627 token_state
= pstTokenIdTbl
[i
].state
;
630 recent_token
= pstTokenIdTbl
[i
].token
+1;
634 return pstTokenIdTbl
[i
].token
+1;
638 str_buff
[str_idx
] = *str
;
641 fprintf(stderr
, "err: word string buffer is over limited.\n");
646 str_idx
= str_idx_bak
;
653 * general proc for text/string. it store string into text buffer.
659 int Txt_TokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
663 strcpy(str_buff
, blank_str
);
664 str_idx
+= strlen(blank_str
);
666 strcat(str_buff
, str
);
667 pstTokenState
->token_len
= strlen(str
);
668 str_idx
+= pstTokenState
->token_len
;
670 printf("Txt_TokenProc(%s) (%s) %d, %d\n", str_buff
, str
, pstTokenState
->token_len
, str_idx
);
674 int String_PunctTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
681 * general proc for text/string. it store string into text buffer.
687 int Macro_TokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
692 char MacroCMDBuff
[16];
694 // printf("Macro_TokenProc(%s)\n", str);
696 /* matching first following word for marco cmd */
697 for (i
=0; i
< str_idx
&& i
<sizeof(MacroCMDBuff
); i
++)
699 if (str_buff
[i
] == ' ') break;
700 MacroCMDBuff
[i
] = str_buff
[i
];
704 // printf("%s(%d)\n", MacroCMDBuff, i);
706 str_idx_bak
= str_idx
;
709 ret
= id_str_matching (
715 str_idx
= str_idx_bak
;
721 * set mask flag/state, the following char will be treated as a WORD char.
723 int Def_MaskTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
725 printf("OnMaskTokenProc(%s)\n", str
);
732 * lookup reserved-word table, maching correspoding token.
733 * or return as a normal T_WORD.
735 int Def_WordTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
737 int len
= strlen(str
);
740 printf("OnWordTokenProc(%s)\n", str
);
742 /* xxx: macro define replacing. */
744 pfn_token_proc
= NULL
;
749 str_buff
[str_idx
] = *str
;
751 str_buff
[str_idx
] = 0;
755 ret
= id_str_matching (
758 pstTokenState
->pstStateInfo
->astTokenTypeTbl
[TYPE_WORD
].pstTokenTbl
,
759 pstTokenState
->pstStateInfo
->api16TokenNameLen
[TYPE_WORD
]);
761 pstTokenState
->pfnTokenProc
= pfn_token_proc
;
762 pstTokenState
->recent_token
= recent_token
;
764 pstTokenState
->token_len
= token_len
;
766 pstTokenState
->token_str
= token_str
;
770 memcpy(str_buff
, str
, str_idx
);
771 str_buff
[str_idx
] = 0;
776 strcpy(str_buff
, str
);
777 str_idx
= strlen(str
);
778 pstTokenState
->token_len
= str_idx
;
785 #define UINT_MAX (-1 & (~0x80000000))
790 * there are three kinds of punct string.
791 * @ prefix-char, this char/str let the program entering a new state.
792 * @ pair-char, also can trig new state.
793 * @ operation-char, for grammar element token.
794 * @ normal-char, T_WORD.
795 * in this function, it recognize and split string, to get one token by looking
796 * up pfx-char/pair-char/opr-char table.
798 int Def_PunctTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
803 int opr_token
, pfx_token
, pair_token
;
804 int opr_idx
, pfx_idx
, pair_idx
;
805 int opr_len
, pfx_len
, pair_len
;
806 TOKEN_ID_PROC opr_proc
= NULL
, pfx_proc
= NULL
, pair_proc
= NULL
;
808 char *tmp_token_str
[3];
810 printf("OnPunctTokenProc(%s)\n", str
);
812 pfn_token_proc
= NULL
;
819 str_buff
[str_idx
] = *str
;
821 str_buff
[str_idx
] = 0;
825 pfx
= id_str_matching (
828 pstTokenState
->pstStateInfo
->astTokenTypeTbl
[TYPE_PFX
].pstTokenTbl
,
829 pstTokenState
->pstStateInfo
->api16TokenNameLen
[TYPE_PFX
]);
830 pfx_token
= recent_token
;
835 pfx_proc
= pfn_token_proc
;
837 tmp_token_str
[0] = token_str
;
838 // printf("pfx = %d\n", pfx);
839 // printf("str_idx = %d\n", str_idx);
840 // printf("pfx_len = %d\n", pfx_len);
843 pair
= id_str_matching (
846 pstTokenState
->pstStateInfo
->astTokenTypeTbl
[TYPE_PAIR
].pstTokenTbl
,
847 pstTokenState
->pstStateInfo
->api16TokenNameLen
[TYPE_PAIR
]);
848 pair_token
= recent_token
;
849 pair_len
= token_len
;
853 pair_proc
= pfn_token_proc
;
855 tmp_token_str
[1] = token_str
;
856 // printf("pair = %d\n", pair);
857 // printf("str_idx = %d\n", str_idx);
858 // printf("pair_len = %d\n", pair_len);
860 opr
= id_str_matching (
863 pstTokenState
->pstStateInfo
->astTokenTypeTbl
[TYPE_PUNCT
].pstTokenTbl
,
864 pstTokenState
->pstStateInfo
->api16TokenNameLen
[TYPE_PUNCT
]);
865 opr_token
= recent_token
;
870 opr_proc
= pfn_token_proc
;
872 tmp_token_str
[2] = token_str
;
873 // printf("opr = %d\n", opr);
874 // printf("str_idx = %d\n", str_idx);
875 // printf("opr_len = %d\n", opr_len);
894 // printf("pfx = %d,%d,%d\n", pfx, pfx_idx, pfx_len);
895 // printf("pair = %d,%d,%d\n", pair, pair_idx, pair_len);
896 // printf("opr = %d,%d,%d\n", opr, opr_idx, opr_len);
898 pfx_idx
<= pair_idx
&& pfx_idx
<= opr_idx
&&
899 pfx_len
>= pair_len
&& pfx_len
>= opr_len
)
901 // printf("xxxxxxxxxxxxxxxx1(%d)\n", pfx);
902 recent_token
= pfx_token
;
905 pfn_token_proc
= pfx_proc
;
906 pstTokenState
->token_str
= tmp_token_str
[0];
910 pair_idx
<= pfx_idx
&& pair_idx
<= opr_idx
&&
911 pair_len
>= pfx_len
&& pair_len
>= opr_len
)
913 /* entering paired token, and need to be switched to new state. */
914 if (token_state
!= 0)
918 pstTokenState
->pfnPairTokenProc
= pfn_pair_token_proc
;
919 pstTokenState
->state_token_str
= state_token_str
;
920 pstTokenState
->paired_token
= pair
+1;
923 pstTokenState
->paired_state
= token_state
;
925 // printf("xxxxxxxxxxxxxxxx2 (%s) pstTokenState->paired_token (%d)\n", pstTokenState->state_token_str, pstTokenState->paired_token);
926 recent_token
= pair_token
;
927 token_len
= pair_len
;
929 pfn_token_proc
= pair_proc
;
930 pstTokenState
->token_str
= tmp_token_str
[1];
934 opr_idx
<= pfx_idx
&& opr_idx
<= pair_idx
&&
935 opr_len
>= pfx_len
&& opr_len
>= pair_len
)
937 // printf("xxxxxxxxxxxxxxxx3(%d)\n", opr);
938 recent_token
= opr_token
;
941 pfn_token_proc
= opr_proc
;
942 pstTokenState
->token_str
= tmp_token_str
[2];
945 // printf("matching ret = %d\n", ret);
947 pstTokenState
->pfnTokenProc
= pfn_token_proc
;
948 pstTokenState
->recent_token
= recent_token
;
950 pstTokenState
->token_len
= token_len
;
957 memcpy(str_buff
, str
, str_idx
);
958 str_buff
[str_idx
] = 0;
961 if (ret
== pfx
&& ret
!= 0)
967 // printf("pstTokenState->token_len = %d;\n", pstTokenState->token_len);
971 strcpy(str_buff
, str
);
972 str_idx
= strlen(str
);
973 pstTokenState
->token_len
= str_idx
;
974 // printf("return T_WORD(%s)\n", str);
978 // printf("return ret = %d\n", ret);
983 int Def_SpaceTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
985 printf("OnSpaceTokenProc(%s)\n", str
);
990 str_buff
[str_idx
] = *str
;
992 str_buff
[str_idx
] = 0;
997 strcpy(blank_str
, str
);
998 str_idx
= strlen(str
);
1000 pstTokenState
->token_len
= str_idx
;
1005 int Def_NewlineTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
1007 printf("OnNewlineTokenProc(%s)\n", str
);
1012 str_buff
[str_idx
] = *str
;
1014 str_buff
[str_idx
] = 0;
1020 pstTokenState
->token_len
= 1;
1021 pstTokenState
->nl_cnt
= strlen(str
) - 1;
1022 // printf("NL(%d)\n", pstTokenState->nl_cnt);
1024 /* in cmd state, new line reset token id num */
1027 if (STATE_VCHK(pstTokenState, STATE_CMD))
1028 pstTokenState->iTokenIdNum = 0;
1034 int Def_EOFTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
1036 printf("OnEOFTokenProc(%s)\n", str
);
1044 int Envar_WordTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
1046 int ret
= Def_WordTokenProc(str
, type
, pstTokenState
);
1048 /* store to prev state. */
1050 if (STATE_VCHK(pstTokenState, STATE_DOLLAR))
1052 STATE_RECOVERY(gpcurr_src_file);
1056 /* envar expanssion */
1059 /* ungetc() to buffer */
1071 int Envar_PunctTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
1073 int ret
= Def_PunctTokenProc(str
, type
, pstTokenState
);
1075 /* store to prev state. */
1077 if (STATE_VCHK(pstTokenState, STATE_DOLLAR))
1079 STATE_RECOVERY(gpcurr_src_file);
1084 if (ret
== T_LBRACKET1
)
1086 STATE_SWITCH(gpcurr_src_file
, STATE_CODE
);
1090 else if (ret
== T_DLBRACKET1
|| ret
== T_LBRACKET2
)
1092 STATE_SWITCH(gpcurr_src_file
, STATE_EXPR
);
1096 else if (ret
== T_LBRACKET3
)
1098 /* XXX: envar expanssion */
1109 /* XXX: expanssion */
1122 int Block_PunctTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
1124 int ret
= Def_WordTokenProc(str
, type
, pstTokenState
);
1126 Txt_TokenProc(str
, type
, pstTokenState
);
1128 /* TBD: append string to buffer */
1136 int Cmnt_WordTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
1138 //int ret = Def_WordTokenProc(str, type, pstTokenState);
1140 /* TBD: append string to buffer */
1142 return Txt_TokenProc(str
, type
, pstTokenState
);
1150 int Cmnt_PunctTokenProc (char *str
, TOKEN_TYPE type
, TOKEN_PROC_STATE
*pstTokenState
)
1152 //int ret = Def_PunctTokenProc(str, type, pstTokenState);
1154 /* TBD: append string to buffer */
1156 return Txt_TokenProc(str
, type
, pstTokenState
);
1161 #include "codeblock.c"