fesch / Structorizer.Desktop

Structorizer is a little tool which you can use to create Nassi-Schneiderman Diagrams (NSD).
https://structorizer.fisch.lu
GNU General Public License v3.0
65 stars 20 forks source link

Code import fails if the source file ends with a line comment in the last non-empty line #1157

Closed codemanyak closed 7 months ago

codemanyak commented 7 months ago

If a source file to be imported ends with a line comment then the parser fails with a "group_runaway" error, e.g. for Java: grafik

If the comment follows in a separate line then the comment itself will not even be shown in the error window, which is even more puzzling.

As the GOLD Parser handles comments as "groups", this problem may be originating in that imported module.

The workaround is simple and straightforward; Remove the final comment before import. Alternatively, the line comment may be converted into a delimited comment: /* end Coco */ in the end would not cause parser failure. Since a comment that does not precede any meaningful language item will not be imported, anyway, it does not matter for the imported diagrams, which of the workarounds is applied.

codemanyak commented 7 months ago

Indeed, GOLDParser generates this kind of error, in "[...] the case where an unterminated comment block consumes the entire [remaining] program". Therefore, simply to append another empty line (which would in theory terminate the line comment) does not help while no substantial syntactical item follows up to the end of file. Of cource, the file preprocessor might automatically check for an endstanding line comment in the last non-blank line and cut if off, but it would then have to make sure that it does not wrongly detect duplicate slashes within string literals, delimited comments or something the like as line comment. So the question is whether it's worth the effort while the manual workaround is so easy.

codemanyak commented 7 months ago

At least we could provide an intelligible translation for the error code: grafik

(In case of a really unterminated comment that is to be delimited like in the screenshot above, this error message still makes sense.)

codemanyak commented 7 months ago

Error reported as https://github.com/ridencww/goldengine/issues/28.