[Chapel Merge] compiler/next: parse class, record and union

Branch: refs/heads/main
Revision: c1bf7e1
Author: mppf
Log Message:

Merge pull request #17945 from mppf/uast-class

compiler/next: parse class, record and union

This PR adds Class, Record, and Union uAST classes, parses them, and adds
a test. It leaves as future work updating convert-uast.cpp to convert
them into something the production compiler can use.

The approach is to create AggregateDecl, a parent class for Class,
Record, and Union. These contain Functions and Variables but it is
possible to know if a Function or Variable is a method or a field by
querying their properties.

While there, it adds a bool field to Function to record if something
was declared as a primary method or not; and likewise a bool field to
Variable to indicate if a Variable is a field. To enable the parser
to compute these correctly, as well as determining the types of the
this receiver for primary methods, added a stack of aggregates
ParserContext.

Lastly, it makes the modest improvement to ASTNode::dump to print out
the bodies of comments.

It leaves the task of converting these new uAST types into the production
AST for future work.

Reviewed by @lydia-duncan and @dlongnecke-cray - thanks!

  • [x] make test-libchplcomp passes

  • [x] full local testing

    Modified Files:
    A compiler/next/include/chpl/uast/AggregateDecl.h
    A compiler/next/include/chpl/uast/Class.h
    A compiler/next/include/chpl/uast/Record.h
    A compiler/next/include/chpl/uast/Union.h
    A compiler/next/lib/uast/AggregateDecl.cpp
    A compiler/next/lib/uast/Class.cpp
    A compiler/next/lib/uast/Record.cpp
    A compiler/next/lib/uast/Union.cpp
    A compiler/next/test/frontend/testParseAggregate.cpp
    M compiler/next/include/chpl/uast/ASTClassesList.h
    M compiler/next/include/chpl/uast/As.h
    M compiler/next/include/chpl/uast/Break.h
    M compiler/next/include/chpl/uast/Builder.h
    M compiler/next/include/chpl/uast/Enum.h
    M compiler/next/include/chpl/uast/Function.h
    M compiler/next/include/chpl/uast/UseClause.h
    M compiler/next/include/chpl/uast/Variable.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/bison-chpl-lib.cpp
    M compiler/next/lib/frontend/Parser/bison-chpl-lib.h
    M compiler/next/lib/frontend/Parser/chpl.ypp
    M compiler/next/lib/uast/ASTNode.cpp
    M compiler/next/lib/uast/CMakeLists.txt
    M compiler/next/lib/uast/Function.cpp
    M compiler/next/lib/uast/Makefile.include
    M compiler/next/lib/uast/Variable.cpp
    M compiler/next/test/frontend/CMakeLists.txt
    M compiler/passes/convert-uast.cpp
    M doc/util/nitpick_ignore

    Compare: Comparing 325e200de848...c1bf7e19c364 · chapel-lang/chapel · GitHub