[Chapel Merge] next: Add Use and support for parsing use statemen

Branch: refs/heads/main
Revision: acab13a
Author: dlongnecke-cray
Log Message:

Merge pull request #17951 from dlongnecke-cray/next-add-use-import

next: Add Use and support for parsing use statements

This is for compiler/next.

Add support for parsing use statements. Represent use statements via
a combination of three nodes:

  • As
  • Use
  • UseClause

A use statement is represented as a Use node in the uAST. It
contains a visibility (e.g. public/private) along with one or more
use clauses of type UseClause.

A UseClause contains a symbol to use, and an optional limitation
clause containing some number of limitations. If a limitation clause
exists, it may be an EXCEPT list or an ONLY list.

The expressions in an EXCEPT list should only be Identifier. The
expressions in an ONLY list may be Identifier or As (they may
be renamed). This will have to be checked by the resolver.

Handle renaming in use statements by introducing the As node. It
contains an Expression called symbol(), which may be a Dot or an
Identifier. It also contains an Identifier called rename().

Also adjust the end() bounds of several statement body iterators by
removing the -1 at the end.

The Import node will be added in a separate effort.

Reviewed by @mppf, @lydia-duncan, @stonea. Thanks!

TESTING:

  • [x] All compiler/next tests pass
  • [x] Could build chpl

Signed-off-by: David Longnecker dlongnecke-cray@users.noreply.github.com

Modified Files:
A compiler/next/include/chpl/uast/As.h

A compiler/next/include/chpl/uast/Use.h
A compiler/next/include/chpl/uast/UseClause.h
A compiler/next/lib/uast/As.cpp
A compiler/next/lib/uast/Use.cpp
A compiler/next/lib/uast/UseClause.cpp
A compiler/next/test/frontend/testParseUse.cpp
M compiler/next/include/chpl/uast/ASTClassesList.h
M compiler/next/include/chpl/uast/Conditional.h
M compiler/next/include/chpl/uast/Loop.h
M compiler/next/include/chpl/uast/SimpleBlockLike.h
M compiler/next/include/chpl/uast/all-uast.h
M compiler/next/lib/frontend/Parser/ParserContext.h
M compiler/next/lib/frontend/Parser/ParserContextImpl.h
M compiler/next/lib/frontend/Parser/chpl.ypp
M compiler/next/lib/frontend/Parser/parser-help.h
M compiler/next/lib/uast/CMakeLists.txt
M compiler/next/lib/uast/Makefile.include
M compiler/next/test/frontend/CMakeLists.txt
M compiler/passes/convert-uast.cpp

Compare: https://github.com/chapel-lang/chapel/compare/433eb592faa6...acab13aa69ed