raullaasner / fortran-tags

Emacs plugin for source code indexing of modern Fortran
GNU General Public License v3.0
18 stars 2 forks source link

attribute error during generation #8

Closed fab6 closed 3 years ago

fab6 commented 3 years ago

Hi,

I am quite new to tagging...

Now, I was trying fortran-tags for a project ( https://github.com/firemodels/fds/tree/master/Source ) Unfortunately I get this error message:

find . -name '*.f90' | xargs ~/.emacs.d/private/local/fortran-tags/fortran-tags.py -g                                                      <<<
Processing input files ... 38%
Error on line /Users/fbraenns/10_TOOLs/CFD/FDS/fds.git/Source/pois.f90:7120:
real(eb)rs

AttributeError: 'NoneType' object has no attribute 'start'
If you consider this a bug, please report at
https://github.com/raullaasner/fortran-tags/issues
Traceback (most recent call last):
  File "/Users/fbraenns/.emacs.d/private/local/fortran-tags/fortran-tags.py", line 545, in <module>
    process_input(input_text, True, TAGS, os.path.abspath(f))
  File "/Users/fbraenns/.emacs.d/private/local/fortran-tags/fortran-tags.py", line 223, in process_input
    position = int((m.start()+m.end())/2)
AttributeError: 'NoneType' object has no attribute 'start'

Do you have an advice how to handle this? Thank you!

fab6 commented 3 years ago

I am running python 3.9.1 on a macos.

raullaasner commented 3 years ago

Thanks for reporting this! The problem is that until now the script assumes that the closing parenthesis is never immediately followed by the variable name (e.g. REAL(EB)RS). But that's an easy fix. I will push it later today because I need to test it first but if you're curious you can already try it yourself:

diff --git a/fortran-tags.py b/fortran-tags.py
index b518736..18494d1 100755
--- a/fortran-tags.py
+++ b/fortran-tags.py
@@ -214,7 +214,7 @@ def process_input(input_text, find_definitions, TAGS='', filepath=''):
                         if scope_count == 1:
                             scope = ':fortags_program_scope:'
                             scope_count = 2
-                        r = '([ ,:&\t]|^)' + name + r'([ ,(\[=!\*\t]|$)'
+                        r = '([ ,:&\t)]|^)' + name + r'([ ,(\[=!\*\t]|$)'
                         m = re.search(r, line_raw)
                         position = int((m.start()+m.end())/2)
                         TAGS.append(f'{filepath} {scope_count} {name} {scope} '
raullaasner commented 3 years ago

Pull the latest version and let me know if there are still issues!

fab6 commented 3 years ago

Thank you, this works now. Though I get now the message:

helm-M-x-execute-command: Incorrect format (regenerate using the current version of Fortran-tags) [2 times]

when executing fortran-find-tag. Do you have an idea? Thank you very much!

raullaasner commented 3 years ago

Could you try remoing FORTAGS in your working directory and trying again? I'm not sure why it would give this error here. If it persists, then it would be good if you could post the Helm portion of your Emacs configuration. I haven't used Helm myself but I can try to reproduce the error.

fab6 commented 3 years ago

Thank you! Hm... still same error. I am using spacemacs with hundres of settings :-( So it might be not so easy to have the same helm settings. I will try it with plain emacs.

fab6 commented 3 years ago

Maybe I can test it on a terminal without emacs!?

raullaasner commented 3 years ago

It is an Emacs statement that gives the error so I don't think it's possible to test it without Emacs. If you know any Lisp, you might be able to debug it by investigating lines 141..148 in fortran-tags.el. That's where the error originates. Is fortran-tags.py in your path? If not, you could try replacing "fortran-tags.py" with its full path everywhere in fortran-tags.el. That's a quick test to see if it works.

Otherwise, I can try to reproduce it on spacemacs but it will take me a bit of time to set it up.

fab6 commented 3 years ago

Thank you for your help! Yes, this works now! Actually I did set the complete path in my config, but not in the fortran-tags.el.