enten / cmpro-dat

ClrMamePro DAT parser for Node.js.
MIT License
0 stars 0 forks source link

Can't parse ROM names with parentheses #1

Open emmercm opened 1 year ago

emmercm commented 1 year ago

The Redump DAT for PlayStation 1 BIOS files (download page) has this ROM name that fails to parse:

game (
    name "ps-22j(v)"
    description "SCPH-5903 (Version 2.2 12/04/95 J)"
    rom ( name ps-22j(v).bin size 1048576 crc 446ec5b2 md5 81328b966e6dcf7ea1e32e55e1c104bb sha1 15c94da3cc5a38a582429575af4198c487fe893c )
)

with the error:

... ame ps-22j(v).bin siz ...
              ^
              Expecting word here, but got '('
enten commented 1 year ago

The current implementation doesn't allow parenthesis for value given without double quotes (because parenthesis is the char used to declare map/object).

Value can use parenthesis only when it's declared between double quotes.

I checked Sony - PlayStation - BIOS Datfile (24) (2016-10-21).dat and I found that 2 changes are required to make the file works with the parser (see patch below).

Can we close this issue?

diff --git a/Sony - PlayStation - BIOS Datfile (24) (2016-10-21).dat b/tmp/Sony - PlayStation - BIOS Datfile (24) (2016-10-21).dat
index 5d0b4d3..d9db2bc 100644
--- a/Sony - PlayStation - BIOS Datfile (24) (2016-10-21).dat
+++ b/Sony - PlayStation - BIOS Datfile (24) (2016-10-21).dat
@@ -57,7 +57,7 @@ game (
 game (
        name "ps-22j(v)"
        description "SCPH-5903 (Version 2.2 12/04/95 J)"
-       rom ( name ps-22j(v).bin size 1048576 crc 446ec5b2 md5 81328b966e6dcf7ea1e32e55e1c104bb sha1 15c94da3cc5a38a582429575af4198c487fe893c )
+       rom ( name "ps-22j(v).bin" size 1048576 crc 446ec5b2 md5 81328b966e6dcf7ea1e32e55e1c104bb sha1 15c94da3cc5a38a582429575af4198c487fe893c )
 )

 game (
@@ -105,7 +105,7 @@ game (
 game (
        name "ps-41a(w)"
        description "SCPH-7000W (Version 4.1 11/14/97 A)"
-       rom ( name ps-41a(w).bin size 524288 crc b7c43dad md5 b84be139db3ee6cbd075630aa20a6553 sha1 1b0dbdb23da9dc0776aac58d0755dc80fea20975 )
+       rom ( name "ps-41a(w).bin" size 524288 crc b7c43dad md5 b84be139db3ee6cbd075630aa20a6553 sha1 1b0dbdb23da9dc0776aac58d0755dc80fea20975 )
 )

 game (
emmercm commented 1 year ago

Unfortunately, I don't have control over the contents of the DAT file, though some pre-processing could be done.

The CMPro spec calls out double quotes for spaces in values only:

Like any programming language you must put quotes around anything that contains spaces.