Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xpath metaparser based on libxml2 #740

Merged
merged 13 commits into from
Jan 21, 2016
Merged

Conversation

masatake
Copy link
Member

ant.c can be rewritten with xpath metaparser.

@masatake
Copy link
Member Author

Remove unnecessary white spaces..

@masatake
Copy link
Member Author

masatake commented Jan 5, 2016

For extension ".xml" we need a good selector.

xmlNode *root;
xmlXPathContextPtr ctx;

findRegexTags ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, for the doctype extraction in the example. sounds a bit hacky, couldn't this be extracted with an Xpath that could get installed at runtime?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive the regex parser here.
See Units/simple-glade.d/args.ctags in these commits.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just an example. What I want to say is that calling findRegexTags is meaningful; it allows a user doing something hacky.

@masatake
Copy link
Member Author

masatake commented Jan 6, 2016

Scope is added but the interface between a concrete parser and xpath meta parser becomes ugly.

 ./ctags -o - ~/var/ctags-github/Units/simple-dbusinspect.d/input.xml  | sed -e 's|/home/yamato/var/ctags-github/Units/simple-dbusinspect.d/||'
</Units/simple-dbusinspect.d/input.xml  | sed -e 's|/home/yamato/var/ctags-github/Units/simple-dbusinspect.d/||'
ClientAdded input.xml   /^    <signal name="ClientAdded">$/;"   s   interface:org.gnome.SessionManager
SessionName input.xml   /^    <property name="SessionName" type="s" access="read">$/;"  p   interface:org.gnome.SessionManager
Setenv  input.xml   /^    <method name="Setenv">$/;"    m   interface:org.gnome.SessionManager
org.gnome.SessionManager    input.xml   /^  <interface name="org.gnome.SessionManager">$/;" i

It seems much more work is needed...

@masatake masatake changed the title xpath metaparser based on libxml2 [RFC] xpath metaparser based on libxml2 Jan 7, 2016
@masatake masatake force-pushed the xpath branch 2 times, most recently from 264b053 to 1663ed3 Compare January 7, 2016 06:02
@masatake masatake changed the title [RFC] xpath metaparser based on libxml2 xpath metaparser based on libxml2 Jan 20, 2016
@masatake
Copy link
Member Author

ugly and inefficient but I implemented generic selector for xml parser family. (2658334).
Now xpath meta parser can be used in real life.
After working on ant.c I would like to merge.

@b4n gives me an homework: using xmlParseMemory instead of xmlParseFile.

@masatake
Copy link
Member Author

The interface of xpath meta parser is updated as @b4n suggested.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…ition of input file

libxml2, which will be used in xpath metaparser, can tell the line
number for a xml node.  However, ctags requires the file position for
a tag when recording. Newly introduced a data structure and functions
will fill this gap.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
TODO: qualified-tags
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Experimental. Testing for new xpath metaparser.
TODO: scope field.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…le contents

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Many of XML meta parser based parsers may have the same extension: xml.
New selector, selectByDTD is for selecting a proper parser for the xml file.

This implementation is not efficient; it crates an dom tree for selecting.
The dom tree should be reused in the selected parser.

This implementation is ugly; per concrete parser rules for selecting are
hard-coded in selectByDTD. These rules should be in parserDefinitions.

Making a XML dom tree from input memory area should be generalized.
So it can be used another areas of ctags.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
I added import(i) kind to ant parser in
b1fa747.

This is a wrong commit now; the imported file should be recorded as a
reference tag. However, current regex meta parser cannot make a
reference tag. So I remove it. Fortunately exuberant-ctags doesn't have
import kind. Therefore this removal doesn't break compatibility.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…cified feature

Units/TEST/features was introduced to specify features needed to run
the TEST case.

This commit introduces a marker for skipping a test case if ctags HAS a
specified feature; the test is skipped if a line of the file is
started with ``!`` marker, and a target ctags have the feature
specified with ``!``.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
scope field is implemented in this xpath based parser.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
masatake added a commit that referenced this pull request Jan 21, 2016
xpath metaparser based on libxml2
@masatake masatake merged commit 2722dce into universal-ctags:master Jan 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants