Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added option to not clip error output.
This is useful for IDEs and other tools that benefit from full path information, so they can jump directly to the error line in the source code. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | lemon-update-2010 |
Files: | files | file ages | folders |
SHA1: |
90602030d18152a934644db119a291aa |
User & Date: | icculus 2010-02-14 05:42:46.000 |
Context
2010-02-14
| ||
17:14 | Make Lemon able to compile as C++ code. (check-in: 75a1060b29 user: icculus tags: lemon-update-2010) | |
05:42 |
Added option to not clip error output.
This is useful for IDEs and other tools that benefit from full path information, so they can jump directly to the error line in the source code. (check-in: 90602030d1 user: icculus tags: lemon-update-2010) | |
05:34 |
Delete output files if this is a failed run.
Otherwise, the fail will stop a Makefile from progressing, but if you immediately run the build again, Make will think the output files are up to date, since they are newer (albeit incomplete/incorrect). (check-in: e38c08d9cd user: icculus tags: lemon-update-2010) | |
Changes
Changes to tool/lemon.c.
︙ | ︙ | |||
1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 | ** The error message is split across multiple lines if necessary. The ** splits occur at a space, if there is a space available near the end ** of the line. */ #define ERRMSGSIZE 10000 /* Hope this is big enough. No way to error check */ #define LINEWIDTH 79 /* Max width of any output line */ #define PREFIXLIMIT 30 /* Max width of the prefix on each line */ void ErrorMsg(const char *filename, int lineno, const char *format, ...){ char errmsg[ERRMSGSIZE]; char prefix[PREFIXLIMIT+10]; int errmsgsize; int prefixsize; int availablewidth; va_list ap; int end, restart, base; | > > > | > > > > > | | | | | | | | | | | | | | | | | | | | | | | | > | 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 | ** The error message is split across multiple lines if necessary. The ** splits occur at a space, if there is a space available near the end ** of the line. */ #define ERRMSGSIZE 10000 /* Hope this is big enough. No way to error check */ #define LINEWIDTH 79 /* Max width of any output line */ #define PREFIXLIMIT 30 /* Max width of the prefix on each line */ static int noerrorclipping = 0; void ErrorMsg(const char *filename, int lineno, const char *format, ...){ char errmsg[ERRMSGSIZE]; char prefix[PREFIXLIMIT+10]; int errmsgsize; int prefixsize; int availablewidth; va_list ap; int end, restart, base; if( noerrorclipping ) { fprintf(stderr, "%s:%d: ", filename, lineno); va_start(ap, format); vfprintf(stderr,format,ap); va_end(ap); fprintf(stderr, "\n"); }else{ va_start(ap, format); /* Prepare a prefix to be prepended to every output line */ if( lineno>0 ){ sprintf(prefix,"%.*s:%d: ",PREFIXLIMIT-10,filename,lineno); }else{ sprintf(prefix,"%.*s: ",PREFIXLIMIT-10,filename); } prefixsize = lemonStrlen(prefix); availablewidth = LINEWIDTH - prefixsize; /* Generate the error message */ vsprintf(errmsg,format,ap); va_end(ap); errmsgsize = lemonStrlen(errmsg); /* Remove trailing '\n's from the error message. */ while( errmsgsize>0 && errmsg[errmsgsize-1]=='\n' ){ errmsg[--errmsgsize] = 0; } /* Print the error message */ base = 0; while( errmsg[base]!=0 ){ end = restart = findbreak(&errmsg[base],0,availablewidth); restart += base; while( errmsg[restart]==' ' ) restart++; fprintf(stdout,"%s%.*s\n",prefix,end,&errmsg[base]); base = restart; } } } /**************** From the file "main.c" ************************************/ /* ** Main program file for the LEMON parser generator. */ |
︙ | ︙ | |||
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 | static int compress = 0; static int quiet = 0; static int statistics = 0; static int mhflag = 0; static int nolinenosflag = 0; static struct s_options options[] = { {OPT_FLAG, "b", (char*)&basisflag, "Print only the basis in report."}, {OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."}, {OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."}, {OPT_FSTR, "T", (char*)handle_T_option, "Specify a template file."}, {OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."}, {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file."}, {OPT_FLAG, "l", (char*)&nolinenosflag, "Do not print #line statements."}, {OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."}, | > | 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 | static int compress = 0; static int quiet = 0; static int statistics = 0; static int mhflag = 0; static int nolinenosflag = 0; static struct s_options options[] = { {OPT_FLAG, "b", (char*)&basisflag, "Print only the basis in report."}, {OPT_FLAG, "e", (char*)&noerrorclipping, "Don't clip error output."}, {OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."}, {OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."}, {OPT_FSTR, "T", (char*)handle_T_option, "Specify a template file."}, {OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."}, {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file."}, {OPT_FLAG, "l", (char*)&nolinenosflag, "Do not print #line statements."}, {OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."}, |
︙ | ︙ |