Related articles |
---|
Complex Constants in Fortran uesu03@giac1.oscs.montana.edu (1993-01-02) |
Re: Complex Constants in Fortran burley@apple-gunkies.gnu.ai.mit.edu (1993-01-04) |
Re: Complex Constants in Fortran jlg@cochiti.lanl.gov (1993-01-04) |
Newsgroups: | comp.compilers |
From: | uesu03@giac1.oscs.montana.edu (Lou Glassy) |
Organization: | Compilers Central |
Date: | Sat, 2 Jan 1993 00:31:45 GMT |
Keywords: | Fortran, parse, question, comment |
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]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.