[Chapel Merge] Implement Visitor to print chapel syntax

Branch: refs/heads/main
Revision: 8a258b1
Author: arezaii
Link: Unavailable
Log Message:

Merge pull request #19275 from arezaii/visitor-pp

Implement Visitor to print chapel syntax

This PR begins implementing the visitor pattern to convert uAST nodes to a
representation of their original chapel syntax.

Work remains to format the output with proper nesting and apply
newlines and semicolons appropriately.

Attributes don't have a syntax printer at the moment, but remains for
future work.

This PR also contains an effort to produce function declarations as the old
parser expects as userStrings. UserStrings are almost identical to chapel
syntax except they lack certain parts of the original declaration such as the
proc or iter keywords. Some examples from the tests:

Chapel syntax / userString:

  • proc bar(x: int) {} / bar(x: int)
  • proc ref C.setClt2(rhs: borrowed C) {} / ref C.setClt2(rhs: borrowed C)
  • inline proc (borrowed object?).hash(): uint / hash(): uint

The functionality required for this was very
similar to that of the chapel syntax visitor, so they are both in the same PR.

This PR also includes a small fix in the old parser where we wouldn't print a
space after the new token when generating the userString and updates
the corresponding .good file. test/classes/delete-free/default-arg-typeless-error.good

TESTING:

  • [x] paratest (0 failures)
  • [x] paratest with --dyno (604 failures, down from 704)

Reviewed by @dlongnecke-cray - thanks!

Signed-off-by: arezaii ahmad.rezaii@hpe.com

Modified Files:
A compiler/dyno/include/chpl/uast/chpl-syntax-printer.h

A compiler/dyno/lib/uast/chpl-syntax-printer.cpp
M compiler/dyno/include/chpl/queries/stringify-functions.h
M compiler/dyno/lib/uast/ASTNode.cpp
M compiler/dyno/lib/uast/CMakeLists.txt
M compiler/dyno/lib/uast/Makefile.include
M compiler/dyno/test/uast/testStringify.cpp
M compiler/include/flex-chapel.h
M compiler/parser/chapel.lex
M compiler/parser/flex-chapel.cpp
M compiler/passes/convert-uast.cpp
M test/classes/delete-free/default-arg-typeless-error.good

Compare: https://github.com/chapel-lang/chapel/compare/2a5be6fe4dc2...8a258b18806a