Patch proposal: Fortran syntax file: Fixed source form detection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Patch proposal: Fortran syntax file: Fixed source form detection

Hendrik Merx
Though not standard-conforming, it is quite common to use a tab instead of six spaces in front of a Fortran fixed source form line where the first five columns are reserved for numeric labels and the sixth column indicating a continuation line. Patching fortran.vim with

--- vim.7.2/runtime/syntax/fortran.vim 2010-05-25 00:38:43.000000000 +0200
+++ custom/fortran.vim 2010-07-09 23:47:36.000000000 +0200
@@ -74,7 +74,7 @@
     " Detection becomes more accurate and time-consuming if more lines
     " are checked. Increase the limit below if you keep lots of comments at
     " the very top of each file and you have a fast computer.
-    let b:lmax = 250
+    let b:lmax = 1024
     if ( b:lmax > line("$") )
       let b:lmax = line("$")
     endif
@@ -82,7 +82,7 @@
     let b:ln=1
     while b:ln <= b:lmax
       let b:test = strpart(getline(b:ln),0,5)
-      if b:test[0] !~ '[Cc*!#]' && b:test !~ '^ \+[!#]' && b:test =~ '[^ 0-9\t]'
+      if b:test !~ '^[ 0-9]*\t' && b:test !~ '^[Cc*]' && b:test !~ '^ *[!#]' && b:test =~ '[^ 0-9\t]'
  let b:fortran_fixed_source = 0
  break
       endif

enhances the detection heuristics to identify such tabbed lines correctly as fixed form.

--

hendrik merx

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Patch proposal: Fortran syntax file: Fixed source form detection

Hendrik Merx
Though not standard-conforming, it is quite common to use a tab instead of six spaces in front of a Fortran fixed source form line where the first five columns are reserved for numeric labels and the sixth column indicating a continuation line. Patching fortran.vim with

--- vim.7.2/runtime/syntax/fortran.vim 2010-05-25 00:38:43.000000000 +0200
+++ custom/fortran.vim 2010-07-09 23:47:36.000000000 +0200
@@ -74,7 +74,7 @@
     " Detection becomes more accurate and time-consuming if more lines
     " are checked. Increase the limit below if you keep lots of comments at
     " the very top of each file and you have a fast computer.
-    let b:lmax = 250
+    let b:lmax = 1024
     if ( b:lmax > line("$") )
       let b:lmax = line("$")
     endif
@@ -82,7 +82,7 @@
     let b:ln=1
     while b:ln <= b:lmax
       let b:test = strpart(getline(b:ln),0,5)
-      if b:test[0] !~ '[Cc*!#]' && b:test !~ '^ \+[!#]' && b:test =~ '[^ 0-9\t]'
+      if b:test !~ '^[ 0-9]*\t' && b:test !~ '^[Cc*]' && b:test !~ '^ *[!#]' && b:test =~ '[^ 0-9\t]'
  let b:fortran_fixed_source = 0
  break
       endif

enhances the detection heuristics to identify such tabbed lines correctly as fixed form.

--

hendrik merx
[hidden email]

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Patch proposal: Fortran syntax file: Fixed source form detection

Tony Mechelynck
On 12/07/10 16:19, Hendrik Merx wrote:
> Though not standard-conforming, it is quite common to use a tab instead of six spaces in front of a Fortran fixed source form line where the first five columns are reserved for numeric labels and the sixth column indicating a continuation line. Patching fortran.vim with
[...]

I thought 1-6 were the line number, and 7 was C for comment, or 1 (then
2 etc.) for continuation?


Best regards,
Tony.
--
Q:  Why did the tachyon cross the road?
A:  Because it was on the other side.

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Patch proposal: Fortran syntax file: Fixed source form detection

Bram Moolenaar
In reply to this post by Hendrik Merx

[forwarding to Ajit]

> Though not standard-conforming, it is quite common to use a tab instead of six spaces in front of a Fortran fixed source form line where the first five columns are reserved for numeric labels and the sixth column indicating a continuation line. Patching fortran.vim with
>
> --- vim.7.2/runtime/syntax/fortran.vim 2010-05-25 00:38:43.000000000 +0200
> +++ custom/fortran.vim 2010-07-09 23:47:36.000000000 +0200
> @@ -74,7 +74,7 @@
>      " Detection becomes more accurate and time-consuming if more lines
>      " are checked. Increase the limit below if you keep lots of comments at
>      " the very top of each file and you have a fast computer.
> -    let b:lmax = 250
> +    let b:lmax = 1024
>      if ( b:lmax > line("$") )
>        let b:lmax = line("$")
>      endif
> @@ -82,7 +82,7 @@
>      let b:ln=1
>      while b:ln <= b:lmax
>        let b:test = strpart(getline(b:ln),0,5)
> -      if b:test[0] !~ '[Cc*!#]' && b:test !~ '^ \+[!#]' && b:test =~ '[^ 0-9\t]'
> +      if b:test !~ '^[ 0-9]*\t' && b:test !~ '^[Cc*]' && b:test !~ '^ *[!#]' && b:test =~ '[^ 0-9\t]'
>   let b:fortran_fixed_source = 0
>   break
>        endif
>
> enhances the detection heuristics to identify such tabbed lines correctly as fixed form.
>
> --
>
> hendrik merx
> [hidden email]

--
FIRST GUARD: Ah!  Now ... we're not allowed to ...
   SIR LAUNCELOT runs him through,  grabs his spear and stabs the other
   guard who collapses in a heap.  Hiccoughs quietly.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Patch proposal: Fortran syntax file: Fixed source form detection

Hendrik Merx
In reply to this post by Tony Mechelynck
Well, almost,

it's columns 1 through 5 for the label which is numeric and thus resembles a line number. It isn't necessary, though, so the first five columns are empty for most lines.

Comment lines have 'C' or '*' in the first column or '!' as the first character.

Continuation lines have any character but '0' in the sixth column, so it's common to count the continuation lines by putting single digits in column 6.

Statements occupy columns 7 to 72, leaving eight characters for a line number on a 80 character punched card. Most, if not all compilers allow more than that.

And, to quote from Annex B 2.6 on obsolescent features of the Fortran 2003 standard:

Fixed form source was designed when the principal machine-readable input medium for new programs was punched cards. Now that new and amended programs are generally entered via keyboards with screen displays, it is an unnecessary overhead, and is potentially error-prone, to have to locate positions 6, 7, or 72 on a line. Free form source was designed expressly for this more modern technology.

Cheers

Hendrik

On Jul 12, 2010, at 16-53, Tony Mechelynck wrote:

> On 12/07/10 16:19, Hendrik Merx wrote:
>> Though not standard-conforming, it is quite common to use a tab instead of six spaces in front of a Fortran fixed source form line where the first five columns are reserved for numeric labels and the sixth column indicating a continuation line. Patching fortran.vim with
> [...]
>
> I thought 1-6 were the line number, and 7 was C for comment, or 1 (then 2 etc.) for continuation?
>
>
> Best regards,
> Tony.
> --
> Q:  Why did the tachyon cross the road?
> A:  Because it was on the other side.

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Patch proposal: Fortran syntax file: Fixed source form detection

Tony Mechelynck
On 13/07/10 13:46, Hendrik Merx wrote:

> Well, almost,
>
> it's columns 1 through 5 for the label which is numeric and thus resembles a line number. It isn't necessary, though, so the first five columns are empty for most lines.
>
> Comment lines have 'C' or '*' in the first column or '!' as the first character.
>
> Continuation lines have any character but '0' in the sixth column, so it's common to count the continuation lines by putting single digits in column 6.
>
> Statements occupy columns 7 to 72, leaving eight characters for a line number on a 80 character punched card. Most, if not all compilers allow more than that.
>
> And, to quote from Annex B 2.6 on obsolescent features of the Fortran 2003 standard:
>
> Fixed form source was designed when the principal machine-readable input medium for new programs was punched cards. Now that new and amended programs are generally entered via keyboards with screen displays, it is an unnecessary overhead, and is potentially error-prone, to have to locate positions 6, 7, or 72 on a line. Free form source was designed expressly for this more modern technology.
>
> Cheers
>
> Hendrik

I see. Wwell, I did some FORTRAN as a freshman in 1967-68 (using
Hollerith cards) and never since then: it's been a long time.


Best regards,
Tony.
--
A novice was trying to fix a broken Lisp machine by turning the power
off and on.  Knight, seeing what the student was doing spoke sternly:
"You can not fix a machine by just power-cycling it with no
understanding of what is going wrong."  Knight turned the machine off
and on.  The machine worked.

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Loading...