ossuminc / riddl

A compiler for the DDD-based design language RIDDL
https://riddl.tech/
Apache License 2.0
23 stars 6 forks source link

[DEFECT] `TopLevelParser.parseRootWithURLs` always returns an empty list of URLs on failure #689

Closed AlexWeinstein92 closed 3 weeks ago

AlexWeinstein92 commented 3 weeks ago

Symptom

The test for failure of parseRootWithURLs expects an empty Seq; the URLs on failure are essential to an ongoing task in the plugin

Expected Behavior

When parseRootWithURLs return Left, the URLs element in the tuples should be populated Ideally the URLs and the Message.Ats would be grouped together so they can be referenced against each other more accurately

Steps To Reproduce

Option 1: Run test return URLs on failure in TopLevelParserTest Option 2: Write a java script using TopLevelParser and make it fail with error messages

reid-spencer commented 3 weeks ago

The behavior of that function is to not return the RPI's top level thing because it could be a string and because the programmer already knows about it. It only returns the URLs of the include statements. If your parse has no includes, you'll get an empty list.

Furthermore, if a parsing error occurs before a single include file has been seen, you won't get anything in that list because the parse is terminated before an include could be processed. Parsing has no ability to correct itself and keep parsing like some compilers do. Consequently, a parsing error will terminate the parsing of THAT file, but other parsers of include files will continue because a new parser is started for each file.

AlexWeinstein92 commented 3 weeks ago

Just needed a clean