Skip to content

Support braceless namespaces #2

@stevenremot

Description

@stevenremot

Hi Joris,

I thought I could give a try to the first milestone in the README so I'm coming with a draft for supporting braceless namespaces so that the following tags are considered to be members of it.

It is implemented in the commit stevenremot/semantic-php@04e98a0 of my fork, in the branch braceless-namespaces.

As the grammar adds the attribute :braceless to this kind of namespaces, my idea is to post-process toplevel parsing to manually integrate the following tags in the namespace. This keeps the grammars simple, but I'm not totally sure there is a proper hook / mode overridable function to do that. For now I have overridden sematic-parse-region and process the tags when there is a full reparse, but this does not seem to work in all cases.

Previously, in my CEDET fork, I handled this case in the grammar, by gathering all tags after a braceless namespace in a kind of "container" tag before putting them in the namespace:

compilation_units
  : T_NAMESPACE namespaced_identifier T_SEMI compilation_units
    (TYPE-TAG $2 $1 (EXPANDTAG $4) nil)
  | compilation_unit compilation_units
    (wisent-php-create-container-tag $2 $1)
  | ;; EMPTY
    (wisent-php-create-container-tag)
  ;

This may be easier, but as you were using the PHP interpreter's grammar as a reference, I tought it may be wiser to leave it unchanged and handle this case in Emacs lisp.

So I will keep going in that direction and improve my new implementation, but I also would like to hear peoples' opinion on all of this. Does someone have any remark on this subject ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions