Branch: refs/heads/master
Revision: bd24013
Author: mppf
Log Message:
Merge pull request #17652 from mppf/add-operator-calls
Add AST nodes for operator calls and parse them
This PR adds support for expressions like a+b
or a = c
or even
a = b + c
to compiler/next.
Some details:
- Move lots of AST node constructors from .cpp to .h files following the
suggested approach in #17648. The rationale for this is that it will
be easier to maintain and they are relatively trivial. To enable that,
added a helper function in ASTList to check if one is just
Expressions. - Adjusts the parser's
%token
declarations to include a type so that
they can be used in semantic actions. The lexer was already storing
the token text in theuniqueStr
union field. - Added several helper methods in ParserContext for common scenarios:
buildEmptyIdent, buildIdent - Added OpCall AST nodes, buildBinOp/buildUnaryOp ParserContext methods,
and parser rules to parse them
Reviewed by @lydia-duncan - thanks!
Modified Files:
A compiler/next/lib/uast/OpCall.cpp
M compiler/next/include/chpl/uast/ASTList.h
M compiler/next/include/chpl/uast/Block.h
M compiler/next/include/chpl/uast/Call.h
M compiler/next/include/chpl/uast/Decl.h
M compiler/next/include/chpl/uast/ErroneousExpression.h
M compiler/next/include/chpl/uast/Expression.h
M compiler/next/include/chpl/uast/FnCall.h
M compiler/next/include/chpl/uast/Identifier.h
M compiler/next/include/chpl/uast/Literal.h
M compiler/next/include/chpl/uast/Module.h
M compiler/next/include/chpl/uast/ModuleDecl.h
M compiler/next/include/chpl/uast/OpCall.h
M compiler/next/include/chpl/uast/Variable.h
M compiler/next/include/chpl/uast/VariableDecl.h
M compiler/next/lib/frontend/Parser/ParserContext.h
M compiler/next/lib/frontend/Parser/ParserContextImpl.h
M compiler/next/lib/frontend/Parser/chapel.ypp
M compiler/next/lib/frontend/Parser/parser-dependencies.h
M compiler/next/lib/uast/ASTList.cpp
M compiler/next/lib/uast/Block.cpp
M compiler/next/lib/uast/CMakeLists.txt
M compiler/next/lib/uast/Call.cpp
M compiler/next/lib/uast/Decl.cpp
M compiler/next/lib/uast/ErroneousExpression.cpp
M compiler/next/lib/uast/Expression.cpp
M compiler/next/lib/uast/FnCall.cpp
M compiler/next/lib/uast/Identifier.cpp
M compiler/next/lib/uast/Module.cpp
M compiler/next/lib/uast/ModuleDecl.cpp
M compiler/next/lib/uast/Variable.cpp
M compiler/next/lib/uast/VariableDecl.cpp
M compiler/next/test/frontend/testParse.cpp
Compare: https://github.com/chapel-lang/chapel/compare/4a90b6d58391...bd24013fd605