berto
Posts: 20708
Joined: 3/13/2002 From: metro Chicago, Illinois, USA Status: offline
|
The following problem is solved! quote:
ORIGINAL: berto Here are some ways we have refined the agelint error messaging to clarify, reduce confusion, and dispel the appearance of false positives. One example: Aliases/NATO Families Images pre Steam.ini, Fri Dec 10 2010 15:06:48 ERROR: in Aliases/NATO Families Images pre Steam.ini, at (or near) line 42: line-specific or other contextual syntax error (else file doesn't end with CR/LF): #s# (0x73), #symbol_admiral_2# 33 $Imgfam76 = symbol_navalengineer.png^M 34 $Imgfam91 = symbol_warship.png^M 35 $Imgfam92 = symbol_warship.png^M 36 $Imgfam93 = symbol_smallsteam.png^M 37 $Imgfam94 = symbol_privateer.png^M 38 $Imgfam95 = symbol_transport.png^M 39 $Imgfam96 = symbol_ironclad.png^M 40 $Imgfam97 = symbol_privateer.png^M 41 $Imgfam112 = symbol_balloons.png^M 42> $Imgfam198 = symbol_admiral_2.png The problem? The ACW "Aliases/NATO Families Images pre Steam.ini" file fails to end "properly", with a proper CR/LF sequence. We can see this by cat'ing the file: [root@berto agelint]# cat "/media/KINGSTON/Games/AGEOD/AGEod's American Civil War/ACW/Aliases/NATO Families Images pre Steam.ini" // Pre-Steam $Imgfam0 = symbol_general_2.png $Imgfam11 = symbol_armyHQ.png $Imgfam12 = symbol_hq1.png $Imgfam21 = symbol_inf.png ... $Imgfam96 = symbol_ironclad.png $Imgfam97 = symbol_privateer.png $Imgfam112 = symbol_balloons.png $Imgfam198 = symbol_admiral_2.png[root@berto agelint]# Do you see where the command prompt, '[root@berto agelint]#' immediately follows the 'symbol_admiral_2.png'? This in itself presents no problem to the AGE engine. The data file will process just fine. But it creates insuperable difficulties for the agelint lexer! Since we really can't solve the lexer problem generally (without adding excessive code complications, or suppressing other possibly legitimate error messages), we mention parenthetically that possible explanation beyond the more generic "line-specific or other contextual syntax error." Note that, in the error output, you can infer the end-of-file, no CR/LF problem because you can see lines of context before the indicated error line but not afterwards. The "line-specific or other contextual syntax error" -- that in itself is an improvement over the previous, simply stated "syntax error". In conjunction with the 'at (or near) line ...', it reminds you to look not just at the indicated line but also at the context. Again, the parsing technology is not always capable of pinpointing the exact point of syntax error, so you sometimes have to look around (usually before). Again, this is not a failure unique to agelint. The C and Perl (and other) compilers also share this limitation. (See earlier posts.) ... So, for example, using the above example, we now have: [root@berto agelint]# ./agelint +e -g acw "Aliases/NATO Families Images pre Steam.ini" [nil] That is, the above agelint command gives no output -- no error message(s) -- hence the file is correctly reported as being error-free. How did I solve this very annoying false positive problem? Through trickery! In agelint.c, when opening the lexer (txt.l) input stream, instead of
txtin = fopen(filecurr, "r"); we now have
static char catcmd[MAXPATH+12];
...
/* a straightforward file read, as in
txtin = fopen(filecurr, "r");
doesn't always work, because some files don't end with
CR/LF, and give the lexer fits (the lexer is line-oriented,
and assumes each line ends with CR/LF); so instead we
open a process that does a 'cat <file>; echo', where
the echo supplies a (sometimes needed, sometimes extra)
file-ending CR/LF, then read the process output -- thereby
tricking the lexer into "thinking" that the final line of
each file ends "properly"
*/
sprintf(catcmd, "cat %c%s%c; echo", '\"', filecurr, '\"');
txtin = popen(catcmd, "r"); So, this annoying category of false positive is gone! A side benefit of this is that, in ERROR statements (all of them!), we can get rid of '(else file doesn't end with CR/LF)' as in ERROR: in /media/KINGSTON/Games/AGEOD/Revolution under Siege FY/RUS/GameData/Abilities/70-Patriot.abi, at (or near) line 14: line-specific or other contextual syntax error (else file doesn't end with CR/LF): #$# (0x24), #$# and instead have the shorter ERROR: in /media/KINGSTON/Games/AGEOD/Revolution under Siege FY/RUS/GameData/Abilities/70-Patriot.abi, at (or near) line 14: line-specific or other contextual syntax error: #$# (0x24), #$# Aside from code improvements like this one, also new additions (chkareas.pl, chkregions.pl), I am now in the process of adapting AGElint to the newly released Alea Jacta Est (AJE). We might expect to see a new AGElint release in the not too distant future.
_____________________________
|