Re: semantic-analyze-possible-completion

David Engster <[email protected]> Sat, 31 Jan 2015 12:02:34 +0100
Newsgroups gmane.emacs.cedet
Message-ID <[email protected]>
fulvio ciriaco writes:
> Hello,
> perhaps Eric could give further advice knowing that the
> fortran <use modulename> clause maps perfectly to the c++
> <using namespace modulename> clause.

No, not perfectly. When you say

  use mymodule

in Fortran, this will also *load* that module. So it's actually a mix of
#include and 'using'.

In the old parser I wrote, I did it like this (in
'semantic-f90-expand-tag'):

- When the parser hits a program, function or subroutine, it gets all
  'use' statements in there (they have to come first).

- The names of those modules are included in an attribute called
  :usedmodules.

- There's an override for semantic-parse-region, which will also search
  for 'use' statements and generate 'include' tag for them, simply by
  adding '.f90' to the name of the module. This is not perfect, but from
  my experience back then, modules were usually handled this way.

  So this code

    program main
      use testmodule
    end program main

  will generate these tags:

  (("testmodule.f90" include nil nil nil)
   ("main" program
    (:usedmodules
     (("testmodule" use nil ...)))))

- By doing this, the parser should automatically try to load and parse
  the file 'testmodule.f90' when you analyze the current context.

- The module in 'testmodule.f90' will be parsed as a separate class
  'module', and it has all its stuff in the :members attribute (see the
  example testmodule.f90' in the tests directory.
 
- The override 'semantic-analyze-scoped-types' will look at the
  :usedmodules attribute, and for each name search for a matching class
  'module', and include all its :members into the current scope.

I hope this helps.
-David

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/