home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.compilers
- Path: sparky!uunet!spool.mu.edu!think.com!spdcc!iecc!compilers-sender
- From: uesu03@giac1.oscs.montana.edu (Lou Glassy)
- Subject: Complex Constants in Fortran
- Reply-To: uesu03@giac1.oscs.montana.edu (Lou Glassy)
- Organization: Compilers Central
- Date: Sat, 2 Jan 1993 00:31:45 GMT
- Approved: compilers@iecc.cambridge.ma.us
- Message-ID: <93-01-003@comp.compilers>
- Keywords: Fortran, parse, question, comment
- Sender: compilers-sender@iecc.cambridge.ma.us
- Lines: 51
-
- A question for those of you who have written Fortran compilers..
-
- Does the scanner resolve complex constants in Fortran, or does
- the parser?
-
- Here's where the question arises. Say you have a hunk of code like
- the following...
-
- X = FU ( 1.0, 3.4 ) ! has to be a function call, but
- ! the scanner doesn't know that...
-
- I'd guess the scanner would return a stream of tokens like
-
- X IDENTIFIER
- = ASSIGNMENT_OPERATOR
- FU IDENTIFIER
-
- and now comes the part I'm curious about. Should the scanner return
-
- ( LEFT_PAREN
- 1.0 REAL_CONSTANT
- , COMMA
- 3.4 REAL_CONSTANT
- ) RIGHT_PAREN
-
- or should the scanner return
-
- (1.0,3.4) COMPLEX_CONSTANT
-
- ???
-
- If I go the first route, then a COMPLEX_CONSTANT must be resolved (or
- 'constructed') by the parser -- which is no great disaster. Conceptually,
- though, it seems that constants of any type should be resolvable by the
- scanner. Is there not enough contextual information available to the
- scanner to do this?
-
- Thanks in advance --
- --
- Lou Glassy (uesu03@giac1.oscs.montana.edu)
- [In INfort I constructed complex constants in the parser because it was
- easier to do that way, and while I was at it I allowed (exp,exp) as a general
- complex expression constructor. It wouldn't have been very hard to do in
- the scanner; there are so many lexical hacks in parsing Fortran already that
- telling whether a complex constant is allowed is easy. In the case above,
- the scanner had better return the list of primitive tokens unless you want to
- add a lot of extra glop to the parser to take complex constants apart in the
- places where they turn out to be pairs of procedure arguments. -John]
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-