Lemon

Check-in [ba7d63db3d]
Login

Check-in [ba7d63db3d]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added functionality to accumulate a string which is written to stdout if not empty after the token stream was feed to the parser.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ba7d63db3df601c541cd4f7c10b7e4e580feb53c
User & Date: wolf 2009-09-03 15:35:52.000
Context
2009-09-03
15:56
Major changes: test-files can now contain a 3 tuple describing a test run; test_runner recognizes this tuples automatically and interprets the 3rd field of the tuple as output which is expected from argscanner
match_output rewritten to be more stable and easier

Minor changes: Some additional logging/debug output. check-in: 263a6138cc user: wolf tags: trunk

15:35
Added functionality to accumulate a string which is written to stdout if not empty after the token stream was feed to the parser. check-in: ba7d63db3d user: wolf tags: trunk
2009-08-21
13:20
Minor code layout thing in argscanner.c fixed (no functional change). Some info output and corrections for the usage message of test_runner.py check-in: 40fc4fd927 user: wolf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to tools/argscanner.c.
95
96
97
98
99
100
101







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118




119
120
121
122
123


124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140


141
142
  int yymajor,                 /* The major token code number */
  ParseTOKENTYPE yyminor       /* The value for the token */
  ParseARG_PDECL               /* Optional %extra_argument parameter */
);

void ParseTrace(FILE *TraceFILE, char *zTracePrompt);








int lookup(char chr);
int lookup(char chr){
	size_t i=0;
	static struct{char chr;int value;} table[]=
	{ 
        LOOKUPTABLE
        /* LOOKUPTABLE should look similiar to {'T',T},* - define
        it as a macro to get as many Tokens as you need. */
	};
	for(i=0;i<sizeof(table)/sizeof(table[0]);i++)
		if(table[i].chr==chr)
			return table[i].value;
    /* else */
	printf("Got a character <%c> which isn't in the lookuptable!\n"
		,chr);
	exit(2);
}





int main(int argc,char** argv){
	char* word="\0";
	void* parser=NULL;
    int   return_code=EXIT_FAILURE;


	parser=ParseAlloc(malloc);

	if(argc==2)
		word=argv[1];

	while(*word!='\0'){
		Parse(parser,lookup(*word),NULL);
		word++;
	}
	Parse(parser,0,0); /* End of input reached */
	/* yyerrcnt is expected to be <= 0 on success and > 0
	 * on error */
	return_code=(((yyParser*)parser)->yyerrcnt>0)?
	    EXIT_FAILURE:EXIT_SUCCESS;
	/* printf("%d\n",((yyParser*)parser)->yyerrcnt); */
	ParseFree(parser,free);
    


	exit(return_code);
}







>
>
>
>
>
>
>

















>
>
>
>





>
>

















>
>


95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
  int yymajor,                 /* The major token code number */
  ParseTOKENTYPE yyminor       /* The value for the token */
  ParseARG_PDECL               /* Optional %extra_argument parameter */
);

void ParseTrace(FILE *TraceFILE, char *zTracePrompt);

/* Default size for our buffer */
#ifndef BUFFSIZE
#define BUFFSIZE 1024
#endif

static char buffer[BUFFSIZE];

int lookup(char chr);
int lookup(char chr){
	size_t i=0;
	static struct{char chr;int value;} table[]=
	{ 
        LOOKUPTABLE
        /* LOOKUPTABLE should look similiar to {'T',T},* - define
        it as a macro to get as many Tokens as you need. */
	};
	for(i=0;i<sizeof(table)/sizeof(table[0]);i++)
		if(table[i].chr==chr)
			return table[i].value;
    /* else */
	printf("Got a character <%c> which isn't in the lookuptable!\n"
		,chr);
	exit(2);
}

void append_string(const char* str){
	strncat(buffer,str,BUFFSIZE-1-strlen(buffer));
}

int main(int argc,char** argv){
	char* word="\0";
	void* parser=NULL;
    int   return_code=EXIT_FAILURE;

	memset(buffer,0,BUFFSIZE);
	parser=ParseAlloc(malloc);

	if(argc==2)
		word=argv[1];

	while(*word!='\0'){
		Parse(parser,lookup(*word),NULL);
		word++;
	}
	Parse(parser,0,0); /* End of input reached */
	/* yyerrcnt is expected to be <= 0 on success and > 0
	 * on error */
	return_code=(((yyParser*)parser)->yyerrcnt>0)?
	    EXIT_FAILURE:EXIT_SUCCESS;
	/* printf("%d\n",((yyParser*)parser)->yyerrcnt); */
	ParseFree(parser,free);
    
	if(*buffer!=0)
		printf("%s\n",buffer);
	exit(return_code);
}