File src/grammar.y changed (mode: 100644) (index 604f860..80f12f3) |
... |
... |
int main(int argc, char **argv) |
29 |
29 |
printf("Got result %d, %s\n", result, yytext); |
printf("Got result %d, %s\n", result, yytext); |
30 |
30 |
} |
} |
31 |
31 |
} |
} |
32 |
|
if (!haderrors) { |
|
33 |
|
printf("Total parse successful: %d lines, no errors\n", totlines); |
|
|
32 |
|
if (!haderrors && didparse) { |
|
33 |
|
printf("Parse successful: %8d lines: %s\n", totlines, "<total>"); |
34 |
34 |
return 0; |
return 0; |
35 |
35 |
} |
} |
36 |
36 |
else { |
else { |
37 |
|
printf("Parse failed: %d total errors\n", haderrors); |
|
|
37 |
|
if (haderrors) |
|
38 |
|
printf("Parse failed: %d error%s total\n", haderrors, haderrors == 1 ? "" : "s"); |
|
39 |
|
else |
|
40 |
|
printf("Parse failed\n"); |
38 |
41 |
return 1; |
return 1; |
39 |
42 |
} |
} |
40 |
43 |
} |
} |
|
... |
... |
intexpr: INTLIT { $$.ty = gInteger; } |
241 |
244 |
; |
; |
242 |
245 |
|
|
243 |
246 |
|
|
244 |
|
funccall: rid LPAREN exprlist RPAREN |
|
245 |
|
; |
|
246 |
|
|
|
247 |
247 |
funcdecl: nativefuncdecl { $$.fd = $1.fd; } |
funcdecl: nativefuncdecl { $$.fd = $1.fd; } |
248 |
248 |
| CONSTANT nativefuncdecl { $$.fd = $2.fd; } |
| CONSTANT nativefuncdecl { $$.fd = $2.fd; } |
249 |
249 |
; |
; |
File src/misc.c changed (mode: 100644) (index ed99897..c0444eb) |
|
1 |
|
// Jass2 parser for bison/yacc |
|
2 |
|
// by Rudi Cilibrasi |
|
3 |
|
// Sun Jun 8 00:51:53 CEST 2003 |
|
4 |
|
// thanks to Jeff Pang for the handy documentation that this was based |
|
5 |
|
// on at http://jass.sourceforge.net |
|
6 |
|
// Released under the BSD license |
1 |
7 |
#include <stdio.h> |
#include <stdio.h> |
2 |
8 |
#include <string.h> |
#include <string.h> |
3 |
9 |
#include <assert.h> |
#include <assert.h> |
|
5 |
11 |
#include "grammar.tab.h" |
#include "grammar.tab.h" |
6 |
12 |
#include "misc.h" |
#include "misc.h" |
7 |
13 |
|
|
|
14 |
|
#define VERSIONSTR "0.91" |
|
15 |
|
|
8 |
16 |
int lineno; |
int lineno; |
9 |
|
int haderrors = 0; |
|
10 |
|
int totlines = 0; |
|
|
17 |
|
int haderrors; |
|
18 |
|
int totlines; |
|
19 |
|
int didparse; |
11 |
20 |
|
|
12 |
21 |
int hashfunc(const char *name); |
int hashfunc(const char *name); |
13 |
22 |
struct hashtable functions, globals, locals, params, types; |
struct hashtable functions, globals, locals, params, types; |
|
... |
... |
void dofile(FILE *fp, const char *name) |
316 |
325 |
while (yyparse()) |
while (yyparse()) |
317 |
326 |
; |
; |
318 |
327 |
if (olderrs == haderrors) |
if (olderrs == haderrors) |
319 |
|
printf("%s parse successful, %d lines\n", curfile, lineno); |
|
|
328 |
|
printf("Parse successful: %8d lines: %s\n", lineno, curfile); |
320 |
329 |
else |
else |
321 |
|
printf("%s failed with %d error%s\n", curfile, haderrors - olderrs,(haderrors == olderrs + 1) ? "s" : ""); |
|
|
330 |
|
printf("%s failed with %d error%s\n", curfile, haderrors - olderrs,(haderrors == olderrs + 1) ? "" : "s"); |
322 |
331 |
totlines += lineno; |
totlines += lineno; |
323 |
332 |
} |
} |
324 |
333 |
|
|
|
334 |
|
void printversion() |
|
335 |
|
{ |
|
336 |
|
printf("pjass version %s by Rudi Cilibrasi\n", VERSIONSTR); |
|
337 |
|
} |
|
338 |
|
|
325 |
339 |
void doparse(int argc, char **argv) |
void doparse(int argc, char **argv) |
326 |
340 |
{ |
{ |
327 |
341 |
int i; |
int i; |
328 |
|
for (i = 1; i < argc; ++i) |
|
329 |
|
if (argv[i][0] == '-' && argv[i][1] == 0) |
|
|
342 |
|
for (i = 1; i < argc; ++i) { |
|
343 |
|
if (argv[i][0] == '-' && argv[i][1] == 0) { |
330 |
344 |
dofile(stdin, "<stdin>"); |
dofile(stdin, "<stdin>"); |
331 |
|
else { |
|
332 |
|
FILE *fp; |
|
333 |
|
fp = fopen(argv[i], "rb"); |
|
334 |
|
dofile(fp, argv[i]); |
|
335 |
|
fclose(fp); |
|
|
345 |
|
didparse = 1; |
|
346 |
|
continue; |
|
347 |
|
} |
|
348 |
|
if (strcmp(argv[i], "-h") == 0) { |
|
349 |
|
printversion(); |
|
350 |
|
printf( |
|
351 |
|
"To use this program, list the files you would like to parse in order.\n" |
|
352 |
|
"If you would like to parse from standard input (the keyboard), then\n" |
|
353 |
|
"use - as an argument. If you supply no arguments to pjass, it will\n" |
|
354 |
|
"parse the console standard input by default.\n" |
|
355 |
|
"To test this program, go into your Scripts directory, and type:\n" |
|
356 |
|
"pjass common.j common.ai Blizzard.j\n" |
|
357 |
|
"pjass accepts some options:\n" |
|
358 |
|
"pjass -h Display this help\n" |
|
359 |
|
"pjass -v Display version information and exit\n" |
|
360 |
|
"pjass - Read from standard input (may appear in a list)\n" |
|
361 |
|
); |
|
362 |
|
exit(0); |
|
363 |
|
continue; |
|
364 |
|
} |
|
365 |
|
if (strcmp(argv[i], "-v") == 0) { |
|
366 |
|
printf("%s version %s\n", argv[0], VERSIONSTR); |
|
367 |
|
exit(0); |
|
368 |
|
continue; |
|
369 |
|
} |
|
370 |
|
FILE *fp; |
|
371 |
|
fp = fopen(argv[i], "rb"); |
|
372 |
|
if (fp == NULL) { |
|
373 |
|
printf("Error: Cannot open %s\n", argv[i]); |
|
374 |
|
continue; |
336 |
375 |
} |
} |
|
376 |
|
dofile(fp, argv[i]); |
|
377 |
|
didparse = 1; |
|
378 |
|
fclose(fp); |
|
379 |
|
} |
337 |
380 |
if (argc == 1) |
if (argc == 1) |
338 |
381 |
dofile(stdin, "<stdin>"); |
dofile(stdin, "<stdin>"); |
339 |
382 |
} |
} |
File src/misc.h changed (mode: 100644) (index 67daac7..e75a46a) |
|
1 |
|
// Jass2 parser for bison/yacc |
|
2 |
|
// by Rudi Cilibrasi |
|
3 |
|
// Sun Jun 8 00:51:53 CEST 2003 |
|
4 |
|
// thanks to Jeff Pang for the handy documentation that this was based |
|
5 |
|
// on at http://jass.sourceforge.net |
|
6 |
|
// Released under the BSD license |
1 |
7 |
#include <stdio.h> |
#include <stdio.h> |
2 |
8 |
#define YYDEBUG 1 |
#define YYDEBUG 1 |
3 |
9 |
|
|
|
... |
... |
void checkParameters(const struct paramlist *func, const struct paramlist *inp); |
67 |
73 |
|
|
68 |
74 |
extern int lineno, totlines; |
extern int lineno, totlines; |
69 |
75 |
extern int haderrors; |
extern int haderrors; |
|
76 |
|
extern int didparse; |
70 |
77 |
extern char *yytext, *curfile; |
extern char *yytext, *curfile; |
71 |
78 |
extern int yydebug; |
extern int yydebug; |
72 |
79 |
extern struct hashtable functions, globals, locals, params, types, *curtab; |
extern struct hashtable functions, globals, locals, params, types, *curtab; |