ridencww / goldengine

Java implementation of Devin Cook's GOLD Parser engine
Other
35 stars 14 forks source link

The engine does not verify the header of the grammar files. #13

Closed teo-tsirpanis closed 10 months ago

teo-tsirpanis commented 9 years ago

According to GOLD Parser's documentation, grammar files have a header at the beginning (cgt class reads it).

However, the Parser class does not check that header. This could lead to more errors.

ridencww commented 9 years ago

It is true that the engine doesn't validate that the header contains the Unicode string "GOLD Parser Tables/1.0", but it does advance beyond the header in order to process the structured data, which raises errors if invalid data is encountered. A check would provide a quick test to see if it is a CGT file being submitted for parsing, but the engine depends to a great degree on having the GOLD Builder produce a correct CGT/EGT file for consumption. A separate class to validate the CGT/EGT file could be written, but I can't remember ever having the GOLD Builder generate an incorrect file that couldn't be handled by the engine. Any errors were due to my implementation of the engine.

Thank you for raising this issue and consider improving my validation of the CGT file if I return to extend engine in the future.

teo-tsirpanis commented 9 years ago

I don't think that a special class is needed. Just return "False" if the header is different.

ridencww commented 9 years ago

I am working on a reported defect and will see if I can add the header check at the same time.