File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 66#define MAXTOKEN 100
77
88enum { NAME , PARENS , BRACKETS };
9+ enum { NO , YES };
910
1011void dcl (void );
1112void dirdcl (void );
@@ -16,6 +17,7 @@ char token[MAXTOKEN]; /* last token string */
1617char name [MAXTOKEN ]; /* indetifier name */
1718char datatype [MAXTOKEN ]; /* data type = char, int, etc. */
1819char out [1024 ]; /* output string */
20+ int prevtoken = NO ; /* to indicate if there was a previous token */
1921
2022int main () {
2123 while (gettoken () != EOF ) { /* 1st token on line */
@@ -50,8 +52,10 @@ void dirdcl(void) {
5052 printf ("error: missing )\n" );
5153 } else if (tokentype == NAME ) /* variable name */
5254 strcpy (name , token );
53- else
55+ else {
5456 printf ("error: expected name or (dcl)\n" );
57+ prevtoken = YES ;
58+ }
5559 while ((type = gettoken ()) == PARENS || type == BRACKETS )
5660 if (type == PARENS )
5761 strcat (out , " function returning" );
@@ -67,6 +71,11 @@ int gettoken(void) /* return next token */ {
6771 void ungetch (int );
6872 char * p = token ;
6973
74+ if (prevtoken == YES ) {
75+ prevtoken = NO ;
76+ return tokentype ;
77+ }
78+
7079 while ((c = getch ()) == ' ' || c == '\t' )
7180 ;
7281 if (c == '(' ) {
You can’t perform that action at this time.
0 commit comments