Hi Klaus,
> Please wait a moment, because IMO your latest defstruct parser has a bug
> (or at least an annoying behavior, see below). here is a working one:
>
> (semantic-elisp-setup-form-parser
> (lambda (form start end)
> (let ((slots (nthcdr 2 form)))
> ;; Skip doc string if present.
> (and (stringp (car slots))
> (setq slots (cdr slots)))
> (semantic-tag-new-type
> (symbol-name (if (consp (nth 1 form))
> (car (nth 1 form))
> (nth 1 form)))
> "struct"
> ;; make tags for the members
> (mapcar (lambda (m)
> (semantic-tag-new-variable
> m nil nil))
> (semantic-elisp-desymbolify (nthcdr 2 form)))
> ;; (semantic-elisp-desymbolify slots)
> (cons nil nil)
> )))
> defstruct
> )
>
[...]
> Well, now we know the problem, the question is now how to deal with - in my
> opinion there are several possible approaches:
> 1. Only semantic tags are allowed as childrens (:members) of a semantic-tag
> (e.g. variable-tags for the members of structs (c, c++) or defstructs
> (elisp)
> 2. ECB (and all other tools using semantic) have to take care that children of
> a tag are not needed to be semantic-tags too and have to deal suitable with
> them
> 3. cedet/semantic allows all API-functions dealing with tags to be called also
> with plain strings (or whatever) and return something suitable
> (e.g. (semantic-tag-name "klaus") returns "klaus" and does not fail
>
> I would vote for 1. but admit that i do really see if this would have
> serious drawbacks?! Approach 2. would be a lot of work for tools like ECB.
> Approach 3. is - hmm, how to say - also somehow clumsy and ugly.....
>
> What do xou think??
I think 1 is the good solution, for example it is what the java parser
produces. So if Eric agree, please commit your fix for the
`defstruct' parser.
[...]
>>> C has something like an alias that you can declare in a "typedef",
>>>and it is a special kind of type which is the type it is aliasing
>>>through the "parent" slot.
[...]
>>Good points Eric! So what do you think of this definition inspired
>>from what the C parser produces for typedefs?
>>
>>(semantic-elisp-setup-form-parser
>> (lambda (form start end)
>> (let ((alias (nth 1 form)))
>> (semantic-tag-new-type
>> ;; If not a quoted symbol evaluate the alias expression.
>> ;; Signal an error if the alias is not a symbol.
>> (symbol-name (if (eq (car alias) 'quote)
>> (cadr alias)
>> (eval alias)))
>> "typedef" ;; Indicate an alias
>> nil nil
>> ;; The following attribute hold the aliased definition.
>> :typedef (nth 2 form)
>> )))
>> defalias
>> )
>
>
> well, i have tried this parser and then i get the following ECB-display of an
> defalias (excerpt of the methods-browser of ECB:
>
[...]
>
> Well, i understand Eric's points and i agree in some aspects but nevertheless
> i found this display of a defalias not really satisfying - for a defvaralias
> it makes more sense - but IMHO a defalias is NOT a type but just another name
> for a function (refernces in C++ are also just other names!)
>
> IMO a defalias should ba parsed as something like a function ans a defvaralias
> as something like a variable because exactly these they are. Both of them are
> not types!
I will let Eric reply to that.
Thanks!
David
|