Re: %use-macros

Eric Ludlam <[email protected]> Sun, 01 Mar 2015 12:03:07 -0500
Newsgroups gmane.emacs.cedet
Message-ID <[email protected]>
On 02/19/2015 04:24 PM, Martin Stein wrote:
> Hi,
>
> In order to simplify integration of the preprocessor (wisent works
> differently than bovine, so I could not simply copy from the only
> example given in C/C++) I wanted to define my own grammar macros with
> %use-macros, which almost works, except for a few problems I could not
> resolve. I have created a semantic/wisent/f90-grammar-macros.el file,
> which contains
>
> (defun semantic-f90-expand0-auxiliary (...)
>     "Auxiliary function."
> ...)
>
> (defun semantic-f90-grammar-macros-EXPAND0 (...)
>     "Fortran 90 EXPAND macro with depth=0 and spp support."
> ...)
>
> (provide 'semantic/wisent/f90-grammar-macros)
>
> According to documentation which confirms with the code I would need to
> put the following into my f90.wy grammar file:
>
> %use-macros semantic-f90-grammar-macros {EXPAND0}
>
> However, the function inserting the macro into actions contains (see
> semantic/grammar.el, line 434ff in function semantic-grammar-use-macros)
>
> (require lib)
>
> where lib = semantic-f90-grammar-macros, which of course is nonsense.
> Naming the file semantic-f90-grammar-macros.el does neither fit the
> usual naming scheme nor does it help anyway. Using
> f90-grammar-macros-EXPAND0 does not help as well, since require still
> needs the path. Is there any other solution I have missed? As use-macros
> is not used anywhere, there is no example I could copy from.
>
> There is another quandary, which leads to a simple albeit strange
> workaround: Replacing (require lib) by (require
> 'semantic/wisent/f90-grammar-macros) works fine, until the compiler
> looks in vain for semantic-f90-expand0-auxiliary which is called from
> within semantic-f90-grammar-macros-EXPAND0. Adding a
> %{
>      (require 'semantic/wisent/f90-grammar-macros)
>      ...
> }
> into my f90.wy file solves this problem. Even more, I can now delete the
> (require 'semantic/wisent/f90-grammar-macros) inside of
> semantic-grammar-use-macros and it still compiles. Almost. In fact,
> f90-grammar-macros is compiled after f90.wy, so whenever I edit
> f90-grammar-macros, I need to touch f90.wy and compile twice, or
> something like this. So I also need to add a dependency, but I could not
> figure out how to do this in Project.ede?
> Or am I doing something fundamtally wrong??

I don't think anyone really knows the wiset use-macros corner of the 
system.  The original author hasn't been around in a while.

Based on looking in grammar.wy think you can put / in the symbol name of 
the library that has the macros, as that character is also used by 
%provide, so that should enable you to get the right naming convention.

As for order of compilation, you can just change the order of the files 
in Project.ede to whatever you want.  I hadn't thought to add 
recompilation directives to the ede grammar target.  We'd have to 
upgrade it to support that.

I'm not sure I helped much.
Eric



------------------------------------------------------------------------------
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/