Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [photran] Syntax Error - Unable to recognize '*' in column 1 as comment

Bernie,
 
I've had similar problems as well.  The only around it is to make it fixed form.  Otherwise it won't view a "C" in column 1 as a comment.  One issue I still have is that we have a comment block at the top of our files that are start with a "C" in column 1 followed for a series of "=" until column 71 then a fiinal "C" in column 72.  The parser flags this as unexpected but we just ignore it. 
 
As for the line continuation, we use a "." in column 6 and it seems to work just fine.
 
-----------------------------------------------------
John David Drake | MTSI
Modeling and Simulation Analyst
phone: 256.417.6744 | fax 256.417.6744
mobile: 615.653.6470 | email: johnathan.drake@xxxxxxxxxxx

From: photran-bounces@xxxxxxxxxxx [photran-bounces@xxxxxxxxxxx] On Behalf Of Scholz, Bernhard (GE Global Research) [scholz@xxxxxx]
Sent: Tuesday, January 08, 2013 7:26 AM
To: Photran Information
Subject: Re: [photran] Syntax Error - Unable to recognize '*' in column 1 as comment

Thanks Daniel for getting back to me. I goofed on my question. I meant to ask why an asterisk in column 1 was not recognized as a start of a comment and instead flagged as an error.

 

The “Writing Code” section of the Photran User’s Guide

(http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.photran.doc.user%2Fhtml%2Fbasic%2FWritingCode.html&cp=50_1_3)

implies  that asterisks can also be used in column 1 to mark a comment:

Photran supports both fixed-form and free-form Fortran code. Photran also supports C preprocessor directives, such as #define, #ifdef, #include, __FILE__, and __LINE__ in Fortran code.

Fixed form is an older form designed for punch cards. It is more common in Fortran 77 and earlier programs, although it is still part of Fortran 2003. In fixed form, a "c", "C", "*", or "!" in column 1 indicates a comment; columns 1 through 5 are used for a statement label; a character in column 6 indicates a continuation line; and program statements are contained in columns 7 through 72. Anything after column 72 is ignored.

 

The Intel compiler I am using seems OK with it.

 

I also noticed that Photran seems unhappy with a “&” character used in column 6 as a continuation line. Actually it does not seem to like any character as a continuation character in column 6.

 

--Bernie

 

 

From: photran-bounces@xxxxxxxxxxx [mailto:photran-bounces@xxxxxxxxxxx] On Behalf Of Daniel Harenberg
Sent: Tuesday, January 08, 2013 2:55 AM
To: Photran Information
Subject: Re: [photran] Syntax Error - Unable to recognize '*' in column 1 as comment

 

(snip)

> Why isn’t an asterisk (‘*’) in column 1 not recognized as an error?

(snip)

I might not get your question right, but it IS recognized as an error by the syntax parser (just as you correctly point out). The star * is not valid, so it complains with 'Unexpected *'. When you add the exclamation mark, it becomes a comment, and the error disappears. So all seems to work fine, and I do not quite get what your question is.

I'll try some further comments that might help:
- Exclamation mark ('!') is the only Fortran 90/95 comment symbol, though the Fortran 77 symbol 'C' continues to be supported. 'C' can only appear in the first column, '!' can appear anywhere.
- The syntax parser is part of Photran, not of the compiler. If you'd try to compile your code snippet without exclamation marks, the compiler would throw an error and abort compilation. With the exclamation marks it would compile fine.

Regarding your second question
(snip)

> Is this something I can change in the configuration?

(snip)
Again I am not sure I get your question, but I'll try an answer: Since comment symbols are part of the (official) Fortran Standard, they can't be changed.


Hope that helps.

Best

Daniel

On 01/07/2013 10:34 PM, Scholz, Bernhard (GE Global Research) wrote:

Folks,

 

I’m brand-new to using Photran and I seem to have a problem right off the bat. It seems that the syntax parser does not like the format of comments in my code.

 

A sample snippet is as follows:

               

**********************************************************************

*      Copyright 2013                                                *

**********************************************************************

*

      program bernie

      implicit none

      print *,'Hello World'

      end program Bernie

 

In the “Outline” window I see a Syntax Exception listed. The Text of the exception is:

               

SyntaxException: Syntax error: Unexpected * (/Ez5_code/bl/bernie.f, line 2, column 1).  Expected one of the following: block, close, contains, abstract, class, identifier, return, interface, call, end of statement, go, print, subroutine, stop, allocatable, end, private, doubleprecision, all, implicit, if, end of input, dimension, goto, write, data, submodule, where, recursive, blockdata, select, allstop, codimension, import, use, intent, pause, backspace, endfile, selectcase, open, associate, elemental, character, nullify, rewind, bind, do, pointer, syncall, program, syncimages, syncmemory, wait, unlock, optional, double, module, read, allocate, equivalence, integer, entry, real, cycle, procedure, pure, integer constant, lock, intrinsic, format, namelist, asynchronous, critical, value, logical, forall, save, sync, inquire, assign, external, volatile, complex, protected, common, endprogram, public, enddo, contiguous, impure, enum, parameter, target, doublecomplex, type, deallocate, function, continue, exit

 

When I add an exclamation point as the first character fir the first 4 lines th syntax error disappears:

!**********************************************************************

!*      Copyright 2013                                                *

!**********************************************************************

!*

      program bernie

      implicit none

      print *,'Hello World'

      end program Bernie

 

Why isn’t an asterisk (‘*’) in column 1 not recognized as an error? Is this something I can change in the configuration?

 

Thanks!

 

--Bernie Scholz

 




_______________________________________________
photran mailing list
photran@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/photran

 


Back to the top