melt-umn / silver

An attribute grammar-based programming language for composable language extensions
http://melt.cs.umn.edu/silver/
GNU Lesser General Public License v3.0
58 stars 7 forks source link

Add genericShow function in silver:core #818

Closed krame505 closed 9 months ago

krame505 commented 10 months ago

Changes

This adds genericShow :: (String ::= a), as a means to turn arbitrary values into strings. This is an improved replacement for hackUnparse, making use of genericPP from silver:langutil:reflect. However genericShow can be used from the runtime and generated code without fear of adding a dependency on the langutil library - the implementation of genericShow calls silver:langutil:reflect:genericPP and silver:langutil:pp:show via Java reflection, falling back to hackUnparse if the langutil library is not availalble.

This function is primarally intended for debugging, diagnostics and error reporting in Silver extension-generated code. Pretty-printing values of known types should be done using the Show type class.

The Silver compiler has been updated to use genericShow in place of hackUnparse.

Documentation

Added a doc comment and updated the doc comment for hackUnparse. Also, deleted a number of now-outdated TODO comments.

Testing

Updated the silver_features and silver_construction test suites to use genericShow in place of hackUnparse. Also, change the testing framework itself to use genericShow in reporting failures.