Enhance DeclTypeSpecVisitor to find derived-type-specs, including with
type parameter values.
Change DerivedTypeSpec so it only needs the name of the derived type,
not the definition, as that isn't necessarily known when we encounter
it.
Fix how memory is managed in DeclTypeSpec: Intrinsic type specs aren't a
problem -- they are one of a few types that live throughout the program.
Derived type specs are dynamically allocated and the memory is owned by
the DeclTypeSpec -- it allocates it when a DeclTypeSpec for a derived
type is created and deletes it when it is destroyed. Pass around
references to TypeSpecs rather than pointers as they can never be null.
In AttrsVisitor, DeclTypeSpecVisitor, ResolveNamesVisitor: make most
functions out-of-line to clean up the class declaration.
In AttrsVisitor, use preprocessor to simplify the simple case of
encountering a parse-tree class causing an attribute to be set.
Handle all such attributes.
Remove old testing code from type.cc.
Remove some of the declarations for IntExpr and IntConst -- they are
only placeholder classes anyway. Don't distinguish kind and length
parameter values.
Original-commit: flang-compiler/f18@e172b51212
Reviewed-on: https://github.com/flang-compiler/f18/pull/36
Tree-same-pre-rewrite: false
Work on scanning compiler directive lines.
Fix glitch in earlier change to parse-state.h.
Add ClassifyLine(), simplify some token sequence data lifetimes and interfaces.
Handle continued directives. Obey !DIR$ FIXED and FREE in prescanner.
Some refactoring of TokenSequence API, then support initial directives (FIXED, FREE, IGNORE_TKR).
Fix !DIR$ IGNORE_TKR syntax, manual was wrong.
Debugging directive scanning & parsing.
Profiling-directed speed-up - do not map cooked source locations to Provenance until a Message is emitted. Turn some non-nullable pointers into references.
Debugging.
Handle !DIR$ IVDEP too, it is in a test.
Accept directives in the execution part.
Original-commit: flang-compiler/f18@fb2ff367ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/34
Tree-same-pre-rewrite: false
This replaces DEFINE_NESTED_ENUM_CLASS in parse-tree.h but works
similarly. "ENUM_CLASS(Foo, A, B, C)" defined enum class Foo with
enumerators A, B, C. It also defines an overloading of EnumToString
that converts enumerators to their string representation.
Change unparse.cc to adapt to this change.
Make use of ENUM_CLASS in attr.h and attr.cc.
Original-commit: flang-compiler/f18@c45b8f172a
Reviewed-on: https://github.com/flang-compiler/f18/pull/31
Create interval.h. Use std::size_t instead of bare size_t. Redefine parser::Name to not be just a bare string.
Break out and rename CharBlock from token-sequence.h for use in the parse tree.
Incremental replacement of name strings with pointers to cooked characters.
Fix case sensitivity problem.
Use new CharBlock encoding to replace strings for real literal constants.
Normalized cooked character stream to lower case.
Simplify parsing now that cooked stream is lower case. Replace Keyword in parse tree.
Add static_asserts to || and recovery parsers to enforce same result types.
Remove needless TODO comment inserted earlier.
Fix case conversion on prefixed character literals (f90_correct/dc04.f90).
Use CharBlock in user-state.h.
Complete transition from nextChar to nextCh (i.e., always use pointers).
Document extensions. Begin work on compiler directive lines.
More documentation work.
Reformat prescan.cc.
More work on compiler directive scanning.
Original-commit: flang-compiler/f18@38d0404e16
Reviewed-on: https://github.com/flang-compiler/f18/pull/29
Tree-same-pre-rewrite: false
Use "namespace Fortran::semantics".
Add helper MakeSymbol() functions to ResolveNameVisitor to make a symbol
in the current scope.
Start work on subroutines, similar to what's been done for functions.
Original-commit: flang-compiler/f18@afe84af1c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/30
A Symbol consists of a common part (in class Symbol) containing name,
owner, attributes. Information for a specific kind of symbol is in a
variant containing one of the *Details classes. So the kind of symbol is
determined by the type of details class stored in the details_ variant.
For scopes there is a single Scope class with an enum indicating the
kind. So far there isn't a need for extra kind-specific details as with
Symbols but that could change. Symbols defined in a Scope are stored
there in a simple map.
resolve-names.cc is a partial implementation of a parse-tree walker that
resolves names to Symbols. Currently is only handles functions (which
introduce a new Scope) and entity-decls. The test-type executable was
reused as a driver for this to avoid the need for a new one.
Sample output is below. When each "end function" is encountered the
scope is dumped, which shows the symbols defined in it.
$ cat a.f90
pure integer(8) function foo(arg1, arg2) result(res)
integer :: arg1
real :: arg2
contains
function bar(arg1)
real :: bar
real :: arg1
end function
end function
$ Debug/tools/f18/test-type a.f90
Subprogram scope: 0 children
arg1: Entity type: REAL
bar: Entity type: REAL
Subprogram scope: 1 children
arg1: Entity type: INTEGER
arg2: Entity type: REAL
bar: Subprogram (arg1)
foo: Subprogram (arg1, arg2) result(res)
res: Entity type: INTEGER(8)
Original-commit: flang-compiler/f18@1cd2fbc04d
Reviewed-on: https://github.com/flang-compiler/f18/pull/30
Tree-same-pre-rewrite: false
Clean out old data structure formatter.
Create stand-alone Parsing class to compose parts of the parser together.
Hello, world!
Better error recovery on command line errors.
Fix bugs from initial run at f77_correct.
Allow parentheses on PROGRAM statement.
Fix Hollerith scanning.
Remove REDIMENSION with good error recovery.
Fix new "spaces" parser, clean up calls to it.
Fix bugs exposed by in38.f90.
Escaped \a is not special to pgf90; get slashes around STRUCTURE name right.
Better multi-byte source encoding support in Hollerith.
Reformat C++.
More work on multi-byte source encoding.
Pass 219 tests in f77_correct, with good excuses for the rest.
Original-commit: flang-compiler/f18@8a1a0aa2dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
This simplifies the "delete and set to null" pattern to just a call to
reset(), and "assign and set to null" to a call to std::move.
The ideal would be a custom deleter that throws an error when an
implicit delete happens but not when reset() is called, but I'm not sure
that's possible.
Original-commit: flang-compiler/f18@f618fc729a
Reviewed-on: https://github.com/flang-compiler/f18/pull/23
This replaces the manual walking code in test-type.cc. It walks the
parse tree and constructs DeclTypeSpec and DerivedTypeDef objects for
each type encountered. It's in a new file, make-types.cc, so that
failing compilations complete faster.
Handle more parts of derived type definitions.
Also some minor cleanups in type.h and type.cc.
Original-commit: flang-compiler/f18@859e7e2665
Reviewed-on: https://github.com/flang-compiler/f18/pull/23
Tree-same-pre-rewrite: false
The classes that were segregated into format-specification.h have
also been grouped into a new Fortran::format namespace.
Code added to tools/f18/f18.cc to run a minimal visitor over
the parse trees resulting from successful parses so that any
future build problems with Walk() will be caught earlier.
Rearrange Walk instances, keep format:: ones together.
Original-commit: flang-compiler/f18@685ddb91ce
Reviewed-on: https://github.com/flang-compiler/f18/pull/22
Add a CLASS_TRAIT macro to idioms.h to define template metaprogramming
based on definable traits of user-defined classes. Tweak the boilerplate
macros in parse-tree.h to add traits to the empty, wrapper, union, and
tuple classes in the parse tree. Replace the macros in parse-tree-visitor.h
with trait-driven templates.
Original-commit: flang-compiler/f18@02400146fb
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
Tree-same-pre-rewrite: false
Add characters.h to consolidate all per-character functions
and reduce dependence on <cctype>.
Add omitted DIRECT= and UNFORMATTED= specifiers to INQUIRE statement.
Add Interval<>, rebase ProvenanceRange upon it, rebase CharPointerWithLength
and rename it ContiguousChars.
Reformat C++.
Original-commit: flang-compiler/f18@78c73c62ba
Reviewed-on: https://github.com/flang-compiler/f18/pull/19
Tree-same-pre-rewrite: false
an unparsing feature.
Enum classes in parse tree node class types are now defined with
a macro so that the names of the enumerations can be captured for
formatting purposes.
Add a TODO comment.
Rebase to new master with parse tree traversal code.
Original-commit: flang-compiler/f18@d6bfcfd526
Reviewed-on: https://github.com/flang-compiler/f18/pull/16
Fortran::FormatItem and UseStmt have both normal fields and a variant
named 'u'. The Walk calls for the normal fields were missing.
These were the only two classes I found where this occurs.
Original-commit: flang-compiler/f18@23b8695a74
Reviewed-on: https://github.com/flang-compiler/f18/pull/17
Unparse takes a parse tree and converts it back to Fortran.
class UnparseVisitor implements a parse tree visitor that emits
the appropriate Fortran source for each node that it visits.
It is only partially implemented so far.
Change f18 to dump the parse tree using Unparse.
Original-commit: flang-compiler/f18@e80c13ec88
Reviewed-on: https://github.com/flang-compiler/f18/pull/15
Group the Walk functions that call WalkTupleClass, WalkUnionClass,
WalkWrapperClass all together, after the ones that don't follow a
simple pattern like that.
Fix the name of the include guard macro.
Original-commit: flang-compiler/f18@711613a4ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/15
Tree-same-pre-rewrite: false
The classes in parse-tree.h that used WRAPPER_CLASS_BOILERPLATE were
accidentally omitted.
Also remove the anonymous namespace around utilities like
WalkWrapperClass as they can be useful outside this file too.
Original-commit: flang-compiler/f18@d47c505441
Reviewed-on: https://github.com/flang-compiler/f18/pull/15
Tree-same-pre-rewrite: false
The thing called on each parse tree node during the walk is still
referred to as a visitor.
Change "pre" to "Pre" and "post" to "Post" to follow the naming
conventions.
Original-commit: flang-compiler/f18@a6ea1296b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/15
Tree-same-pre-rewrite: false
Add VisitWrapperClass, VisitTupleClass, and VisitVariantClass to
simplify the common cases in the parse tree. ForEachInTuple is used to
implement VisitTupleClass.
Original-commit: flang-compiler/f18@c6ae2b833b
Reviewed-on: https://github.com/flang-compiler/f18/pull/15
Tree-same-pre-rewrite: false
comments, continuations, &c. that have become obsolete with the use
of the new C++-coded prescanner module. Clean out members from
ParseState that were used only by cookedNextChar and its sub-parsers.
Original-commit: flang-compiler/f18@41717531e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/11
Tree-same-pre-rewrite: false
Now the only targets in Makefile are Debug, Release, and reformat.
"make reformat" reformats all C++ source in place.
Also includes the result of "make reformat". Most of the changes were
just moving the "main" include up.
Original-commit: flang-compiler/f18@cf7d3a7afb