hansec / autocomplete-fortran

https://atom.io/packages/autocomplete-fortran
MIT License
16 stars 0 forks source link

Error parsing file: Scope stack not empty #8

Closed hzxusx closed 7 years ago

hzxusx commented 7 years ago

Hi, I have just installed this package and encounter this problem. I read the previous posts but found no answer.

First, I test the example.f90 and test_mod.f90 (which I typed according to the gif in the homepage) in one project again and it worked.

But when I try another file it behaves abnormally. It's a f77 code from my PIC simulation course. Of course it will compile (using gfortran).

The default setting uses '/usr/bin/python', and this produces the Scope stack not empty error

$ /usr/bin/python /home/hzxusx/.atom/packages/autocomplete-fortran/python/parse_fortran.py -d --fixed --files=../atom-pic/code.1.f 
program beps2k !!! PROGRAM statement(2)
complex*16 qc,fxc,fyc,sct !!! VARIABLE statement(4)
subroutine distr2(part,nss,idimp,idimv,vbe,vte,npx,npy,nop,nx,ny) !!! SUBROUTINE statement(124)
subroutine distri(part,idimp,idimv,vbi,vti,npx,npy,nop,nx,ny) !!! SUBROUTINE statement(178)
subroutine dpost2(part,q,qs,dns,qm,nop,nss,idimp,idimv,nx,ny,nxv) !!! SUBROUTINE statement(232)
subroutine dposti(part,q,nop,idimp,idimv,nx,ny,nxv) !!! SUBROUTINE statement(310)
subroutine pois2(q,fx,fy,isign,ffc,ax,ay,affp,wp,nx,ny,nxv,nyhd) !!! SUBROUTINE statement(374)
idimp,idimv,nop,nx,ny,nxv,ek) !!! SUBROUTINE statement(486)
nop,nx,ny,nxv,ek) !!! SUBROUTINE statement(606),idimv,
nxhyd,nxyhd) !!! SUBROUTINE statement(722)ndy,nxhd,nyd,
complex*16 f, sct, t1, t2, t3 !!! VARIABLE statement(750)
function ranorm(d) !!! FUNCTION statement(972)
integer r1,r2,r4,r5 !!! VARIABLE statement(980)
double precision ranorm,h1l,h1u,h2l,r0,r3,asc,bsc,temp,d !!! VARIABLE statement(981)
{"error": "Scope stack not empty"}

And in this case, when clicking rebulid index, I get the Scope stack not empty error

If I type python directly, which means using the python3 provided by anaconda, it seems to work

$ which python
/home/hzxusx/anaconda3/bin/python
$ python /home/hzxusx/.atom/packages/autocomplete-fortran/python/parse_fortran.py -d --fixed --files=../atom-pic/code.1.f 
program beps2k !!! PROGRAM statement(2)
complex*16 qc,fxc,fyc,sct !!! VARIABLE statement(4)
end !!! END scope(121)
subroutine distr2(part,nss,idimp,idimv,vbe,vte,npx,npy,nop,nx,ny) !!! SUBROUTINE statement(124)
end !!! END scope(175)
subroutine distri(part,idimp,idimv,vbi,vti,npx,npy,nop,nx,ny) !!! SUBROUTINE statement(178)
end !!! END scope(227)
subroutine dpost2(part,q,qs,dns,qm,nop,nss,idimp,idimv,nx,ny,nxv) !!! SUBROUTINE statement(232)
end !!! END scope(305)
subroutine dposti(part,q,nop,idimp,idimv,nx,ny,nxv) !!! SUBROUTINE statement(310)
end !!! END scope(370)
subroutine pois2(q,fx,fy,isign,ffc,ax,ay,affp,wp,nx,ny,nxv,nyhd) !!! SUBROUTINE statement(374)
end !!! END scope(483)
subroutine push2(part,fx,fy,dns,nss,bx0,by0,qm,dt,idimp,idimv,nop,nx,ny,nxv,ek) !!! SUBROUTINE statement(486)
end !!! END scope(600)
subroutine pushi(part,fx,fy,bx0,by0,qm,dt,idimp,idimv,nop,nx,ny,nxv,ek) !!! SUBROUTINE statement(606)
end !!! END scope(716)
subroutine fft2rx(f,isign,mixup,sct,indx,indy,nxhd,nyd,nxhyd,nxyhd) !!! SUBROUTINE statement(722)
complex*16 f, sct, t1, t2, t3 !!! VARIABLE statement(750)
end !!! END scope(969)
function ranorm(d) !!! FUNCTION statement(972)
integer r1,r2,r4,r5 !!! VARIABLE statement(980)
double precision ranorm,h1l,h1u,h2l,r0,r3,asc,bsc,temp,d !!! VARIABLE statement(981)
end !!! END scope(1031)
{"scopes":["beps2k","distr2","distri","dpost2","dposti","pois2","push2","pushi","fft2rx","ranorm"],"objs":{"ranorm::r0":{"desc":"DOUBLE PRECISION","fdef":981,"type":6,"name":"r0"},"beps2k::qc":{"desc":"COMPLEX*16","fdef":4,"type":6,"name":"qc"},"ranorm::r2":{"desc":"INTEGER","fdef":980,"type":6,"name":"r2"},"pois2":{"mem":[],"fbound":[374,483],"type":2,"desc":"SUBROUTINE","args":"q,fx,fy,isign,ffc,ax,ay,affp,wp,nx,ny,nxv,nyhd","name":"pois2"},"ranorm::r3":{"desc":"DOUBLE PRECISION","fdef":981,"type":6,"name":"r3"},"ranorm::r4":{"desc":"INTEGER","fdef":980,"type":6,"name":"r4"},"ranorm::d":{"desc":"DOUBLE PRECISION","fdef":981,"type":6,"name":"d"},"push2":{"mem":[],"fbound":[486,600],"type":2,"desc":"SUBROUTINE","args":"part,fx,fy,dns,nss,bx0,by0,qm,dt,idimp,idimv,nop,nx,ny,nxv,ek","name":"push2"},"fft2rx::sct":{"desc":"COMPLEX*16","fdef":750,"type":6,"name":"sct"},"distri":{"mem":[],"fbound":[178,227],"type":2,"desc":"SUBROUTINE","args":"part,idimp,idimv,vbi,vti,npx,npy,nop,nx,ny","name":"distri"},"dpost2":{"mem":[],"fbound":[232,305],"type":2,"desc":"SUBROUTINE","args":"part,q,qs,dns,qm,nop,nss,idimp,idimv,nx,ny,nxv","name":"dpost2"},"ranorm::h2l":{"desc":"DOUBLE PRECISION","fdef":981,"type":6,"name":"h2l"},"beps2k::fxc":{"desc":"COMPLEX*16","fdef":4,"type":6,"name":"fxc"},"ranorm::asc":{"desc":"DOUBLE PRECISION","fdef":981,"type":6,"name":"asc"},"ranorm::bsc":{"desc":"DOUBLE PRECISION","fdef":981,"type":6,"name":"bsc"},"dposti":{"mem":[],"fbound":[310,370],"type":2,"desc":"SUBROUTINE","args":"part,q,nop,idimp,idimv,nx,ny,nxv","name":"dposti"},"ranorm::h1u":{"desc":"DOUBLE PRECISION","fdef":981,"type":6,"name":"h1u"},"fft2rx::f":{"desc":"COMPLEX*16","fdef":750,"type":6,"name":"f"},"ranorm::temp":{"desc":"DOUBLE PRECISION","fdef":981,"type":6,"name":"temp"},"beps2k::fyc":{"desc":"COMPLEX*16","fdef":4,"type":6,"name":"fyc"},"ranorm::h1l":{"desc":"DOUBLE PRECISION","fdef":981,"type":6,"name":"h1l"},"beps2k":{"fbound":[2,121],"mem":["qc","fxc","fyc","sct"],"desc":"PROGRAM","type":1,"name":"beps2k"},"fft2rx":{"mem":["f","sct","t1","t2","t3"],"fbound":[722,969],"type":2,"desc":"SUBROUTINE","args":"f,isign,mixup,sct,indx,indy,nxhd,nyd,nxhyd,nxyhd","name":"fft2rx"},"fft2rx::t3":{"desc":"COMPLEX*16","fdef":750,"type":6,"name":"t3"},"beps2k::sct":{"desc":"COMPLEX*16","fdef":4,"type":6,"name":"sct"},"ranorm::r5":{"desc":"INTEGER","fdef":980,"type":6,"name":"r5"},"pushi":{"mem":[],"fbound":[606,716],"type":2,"desc":"SUBROUTINE","args":"part,fx,fy,bx0,by0,qm,dt,idimp,idimv,nop,nx,ny,nxv,ek","name":"pushi"},"fft2rx::t2":{"desc":"COMPLEX*16","fdef":750,"type":6,"name":"t2"},"ranorm":{"mem":["r1","r2","r4","r5","ranorm","h1l","h1u","h2l","r0","r3","asc","bsc","temp","d"],"fbound":[972,1031],"type":3,"desc":"FUNCTION","args":"d","name":"ranorm"},"ranorm::r1":{"desc":"INTEGER","fdef":980,"type":6,"name":"r1"},"distr2":{"mem":[],"fbound":[124,175],"type":2,"desc":"SUBROUTINE","args":"part,nss,idimp,idimv,vbe,vte,npx,npy,nop,nx,ny","name":"distr2"},"ranorm::ranorm":{"desc":"DOUBLE PRECISION","fdef":981,"type":6,"name":"ranorm"},"fft2rx::t1":{"desc":"COMPLEX*16","fdef":750,"type":6,"name":"t1"}}}

However, in the file, some identifier works and jumps to the right position, some don't and produce Could not find definition: ...

You can find the code I use here. I don't own the copyright so please use for test only.

By the way, if I open mutiple projects, does the rebuild index build them all?

Some information

Atom    : 1.14.3
Electron: 1.3.13
Chrome  : 52.0.2743.82
Node    : 6.5.0
Python : 2.7.12
Python(anaconda) : 3.5.2
OS : Ubuntu 16.04
hansec commented 7 years ago

Ok, I think I was able to track down the problem. Can you please try this updated parser script with your default Python install? You can download the file using the "raw" link at the top of the source code.

hzxusx commented 7 years ago

Great! It works properly now. Thanks for your help!

hansec commented 7 years ago

@hzxusx In response to your other questions.

1) The code you are working with uses implicit variables. These variables are never really defined in the conventional sense, so they are not picked up for suggestion. I may try and improve handling that type of variable in the future, but it is not a high priority since using implicit variables is no longer considered best practice.

2) Each window in Atom is independent, so rebuild index only rebuilds the current project, not those open in other windows.