Commit graph

1150 commits

Author SHA1 Message Date
peter klausler
d71f3cf532 [flang] More unparsing.
Original-commit: flang-compiler/f18@a3ef9de518
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-14 16:31:41 -07:00
peter klausler
b7cf512e0d [flang] Incorporate more code review comments, fix more f90.
Original-commit: flang-compiler/f18@2428121ab4
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-14 15:31:16 -07:00
peter klausler
b28ea527b4 [flang] Address review comments. Add note to style guide condemning if((x=y)).
Original-commit: flang-compiler/f18@4ca8b8e514
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-13 17:20:40 -07:00
peter klausler
46c3538c7a [flang] Fix some F90 unparsings; address review comments.
Original-commit: flang-compiler/f18@af33f37600
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-13 17:11:26 -07:00
peter klausler
d39a33f80c [flang] Start on f90_correct. Incorporate review comments.
Original-commit: flang-compiler/f18@3f8cecef8e
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-13 16:59:30 -07:00
peter klausler
47dbbda25d [flang] Bugfixing and review comments.
Original-commit: flang-compiler/f18@29cabc7100
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-13 16:47:48 -07:00
peter klausler
79d044e9b5 [flang] Take flang-compiler/f18#2 on unparsing, now using the new parse tree walker.
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
2018-03-13 16:32:09 -07:00
Tim Keith
6fab60d6db [flang] Merge pull request flang-compiler/f18#23 from ThePortlandGroup/tsk4
Add MakeTypes to build types using visitor.

Original-commit: flang-compiler/f18@30a4b46d4b
Reviewed-on: https://github.com/flang-compiler/f18/pull/23
2018-03-01 18:09:18 -08:00
Tim Keith
01580dd19a [flang] Replace raw pointers with std::unique_ptr.
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
2018-03-01 18:04:05 -08:00
Tim Keith
600788e5f7 [flang] Add MakeTypes to build types using visitor.
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
2018-03-01 15:24:35 -08:00
Peter Klausler
801378a5f0 [flang] Merge pull request flang-compiler/f18#22 from ThePortlandGroup/pmk-fix2
Ensure that the parse tree visitation Walk template works on FORMAT.

Original-commit: flang-compiler/f18@e693dd320d
Reviewed-on: https://github.com/flang-compiler/f18/pull/22
2018-03-01 14:47:28 -08:00
peter klausler
20364f0351 [flang] Ensure that the parse tree visitation Walk template works on FORMAT.
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
2018-03-01 13:35:58 -08:00
Peter Klausler
c88b23e04e [flang] Merge pull request flang-compiler/f18#21 from ThePortlandGroup/pmk-fix
Fix parsing error on PROCEDURE statement in derived type definition.

Original-commit: flang-compiler/f18@e9c218df42
Reviewed-on: https://github.com/flang-compiler/f18/pull/21
2018-03-01 13:34:48 -08:00
peter klausler
1b0705ca0f [flang] Fix parsing error on PROCEDURE statement in derived type definition.
Improve error recovery in that context.

Original-commit: flang-compiler/f18@b9e48504e6
Reviewed-on: https://github.com/flang-compiler/f18/pull/21
2018-03-01 11:28:13 -08:00
Peter Klausler
a4a355940c [flang] Merge pull request flang-compiler/f18#20 from ThePortlandGroup/pmk-traits
Trait-based parse tree traversal.

Original-commit: flang-compiler/f18@0f8a4aaf07
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
2018-02-28 14:59:03 -08:00
peter klausler
aa3aad34ea [flang] Follow own new style rule about returns and elses.
Original-commit: flang-compiler/f18@665fdf72d1
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
2018-02-28 14:55:45 -08:00
peter klausler
65ed9e1dae [flang] Run clang-format.
Original-commit: flang-compiler/f18@cd52d99f21
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
Tree-same-pre-rewrite: false
2018-02-28 14:53:04 -08:00
peter klausler
601e0acdeb [flang] Improvements suggested by Tim.
Original-commit: flang-compiler/f18@c3d2e3e745
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
Tree-same-pre-rewrite: false
2018-02-28 14:51:45 -08:00
peter klausler
07a028098f [flang] Trait-based parse tree traversal.
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
2018-02-28 13:24:01 -08:00
Tim Keith
848bf57051 [flang] Merge pull request flang-compiler/f18#18 from ThePortlandGroup/tsk1
Use macros to reduce boilerplate.

Original-commit: flang-compiler/f18@b9f25364a8
Reviewed-on: https://github.com/flang-compiler/f18/pull/18
2018-02-27 16:52:29 -08:00
Tim Keith
de65ddbae0 [flang] Use macros to reduce boilerplate.
The common cases of wrapper, tuple, and union classes can be further
reduced by using macros to define the Walk functions.

Original-commit: flang-compiler/f18@29e02c4886
Reviewed-on: https://github.com/flang-compiler/f18/pull/18
2018-02-27 16:52:29 -08:00
Peter Klausler
c986245a85 [flang] Merge pull request flang-compiler/f18#19 from ThePortlandGroup/pmk-fix-master
Fix some bugs that I noticed while running regression tests.

Original-commit: flang-compiler/f18@0d6c927f8f
Reviewed-on: https://github.com/flang-compiler/f18/pull/19
2018-02-27 16:35:08 -08:00
peter klausler
48f7c6f0fd [flang] Fix test: do not allow & as continuation marker in fixed form if in a character literal.
Original-commit: flang-compiler/f18@26c07eb2e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/19
2018-02-27 16:33:10 -08:00
peter klausler
f4a85288db [flang] Fix some bugs that I noticed while running regression tests.
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
2018-02-27 15:55:10 -08:00
Peter Klausler
089796d643 [flang] Merge pull request flang-compiler/f18#16 from ThePortlandGroup/pmk-minor
Preserve some minor changes...

Original-commit: flang-compiler/f18@7b3e4908bd
Reviewed-on: https://github.com/flang-compiler/f18/pull/16
2018-02-26 16:00:43 -08:00
peter klausler
03aecfc336 [flang] Preserve some minor changes that accumulated as I was implementing
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
2018-02-26 15:31:46 -08:00
Tim Keith
c36ac6b185 [flang] Merge pull request flang-compiler/f18#17 from ThePortlandGroup/tsk1
Fix classes with variant and other fields

Original-commit: flang-compiler/f18@1c2f9e8e8a
Reviewed-on: https://github.com/flang-compiler/f18/pull/17
2018-02-26 15:12:10 -08:00
Tim Keith
66c9a69a61 [flang] Fix classes with variant and other fields
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
2018-02-26 15:07:24 -08:00
Tim Keith
c2c6e28cec [flang] Merge pull request flang-compiler/f18#15 from ThePortlandGroup/tsk1
First implementation of a parse tree visitor

Original-commit: flang-compiler/f18@b9a9d249f3
Reviewed-on: https://github.com/flang-compiler/f18/pull/15
2018-02-26 14:52:27 -08:00
Tim Keith
2af29bc1e2 [flang] Add Unparse function.
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
2018-02-26 14:52:27 -08:00
Tim Keith
0406170acb [flang] Reorder the Walk functions.
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
2018-02-26 14:52:27 -08:00
Tim Keith
686529a59a [flang] Add some missing Walk functions.
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
2018-02-26 14:52:27 -08:00
Tim Keith
2ca306abe1 [flang] Rename "visit" to "Walk" to avoid conflict with std::visit.
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
2018-02-26 14:52:27 -08:00
Tim Keith
a9c3093b2e [flang] Add helpers for wrapper/tuple/variant classes.
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
2018-02-26 14:52:27 -08:00
Tim Keith
9f07a4a3d8 [flang] First implementation of a parse tree visitor
Original-commit: flang-compiler/f18@0b441831f4
Reviewed-on: https://github.com/flang-compiler/f18/pull/15
Tree-same-pre-rewrite: false
2018-02-26 14:52:27 -08:00
Stephane Chauveau
ad68e77db2 [flang] Merge pull request flang-compiler/f18#13 from ThePortlandGroup/sch1
Add simple recursive CMake directory structure

Original-commit: flang-compiler/f18@c20c4a34ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/13
2018-02-22 11:24:53 +01:00
Stephane Chauveau
78f3c745ea [flang] Add missing include config file skeleton
Original-commit: flang-compiler/f18@beb71e4e4b
Reviewed-on: https://github.com/flang-compiler/f18/pull/13
2018-02-19 14:44:54 +01:00
Stephane Chauveau
8f6f23fc54 [flang] Add simple recursive CMake directory structure
Original-commit: flang-compiler/f18@a021b2ca76
Reviewed-on: https://github.com/flang-compiler/f18/pull/13
Tree-same-pre-rewrite: false
2018-02-19 14:28:12 +01:00
klausler
6ca3ca3c6e [flang] Merge pull request flang-compiler/f18#14 from ThePortlandGroup/pmk-msg
Put localization markers on the string literals used for messages.

Original-commit: flang-compiler/f18@93089c2bc6
Reviewed-on: https://github.com/flang-compiler/f18/pull/14
2018-02-21 13:45:47 -08:00
peter klausler
c3a2d82d3e [flang] Support localizable formatted messages.
Original-commit: flang-compiler/f18@e974321494
Reviewed-on: https://github.com/flang-compiler/f18/pull/14
2018-02-21 12:12:52 -08:00
peter klausler
2bfdbb87b7 [flang] Fix bug with "expected ..." messages in token strings.
Original-commit: flang-compiler/f18@9cc84ba6fb
Reviewed-on: https://github.com/flang-compiler/f18/pull/14
Tree-same-pre-rewrite: false
2018-02-20 10:35:04 -08:00
peter klausler
3b544af6da [flang] Use "..."_en_US for messages.
Original-commit: flang-compiler/f18@fffa881576
Reviewed-on: https://github.com/flang-compiler/f18/pull/14
Tree-same-pre-rewrite: false
2018-02-20 09:57:30 -08:00
peter klausler
206db251b7 [flang] Convert all messages to MessageTexts ("..."_msg).
Original-commit: flang-compiler/f18@33357f3657
Reviewed-on: https://github.com/flang-compiler/f18/pull/14
Tree-same-pre-rewrite: false
2018-02-16 16:57:40 -08:00
peter klausler
5e83ea521c [flang] Define MessageText and "..."_msg.
Original-commit: flang-compiler/f18@6e9e16431c
Reviewed-on: https://github.com/flang-compiler/f18/pull/14
Tree-same-pre-rewrite: false
2018-02-16 15:47:30 -08:00
klausler
4a6e4002e1 [flang] Merge pull request flang-compiler/f18#12 from ThePortlandGroup/pmk1
Update the header file guards in lib/parser to reflect the introducti…

Original-commit: flang-compiler/f18@5ad8f67f4a
Reviewed-on: https://github.com/flang-compiler/f18/pull/12
2018-02-16 11:49:47 -08:00
peter klausler
dd9923bf45 [flang] Update the header file guards in lib/parser to reflect the introduction of the parser namespace.
Original-commit: flang-compiler/f18@a11bb88396
Reviewed-on: https://github.com/flang-compiler/f18/pull/12
2018-02-16 11:42:17 -08:00
klausler
1d09d20b3a [flang] Merge pull request flang-compiler/f18#11 from ThePortlandGroup/pmk1
Remove old character "cooking" parser combinators

Original-commit: flang-compiler/f18@def973c39c
Reviewed-on: https://github.com/flang-compiler/f18/pull/11
2018-02-16 11:03:54 -08:00
peter klausler
a60d201dc9 [flang] Reformatting and some comment clean-up.
Original-commit: flang-compiler/f18@cedd3d82cf
Reviewed-on: https://github.com/flang-compiler/f18/pull/11
2018-02-16 10:58:17 -08:00
peter klausler
7af9dd8736 [flang] Remove old character "cooking" parser combinators that handled Fortran
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
2018-02-16 10:41:16 -08:00
klausler
3185562e19 [flang] Merge pull request flang-compiler/f18#10 from ThePortlandGroup/pmk2
Remove a temporary #include <iostream> and auto-detect -Mfixed

Original-commit: flang-compiler/f18@93ecf8d908
Reviewed-on: https://github.com/flang-compiler/f18/pull/10
2018-02-16 09:25:44 -08:00