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

Question regarding merging parsers #101

Open
ThibautVerron opened this issue Oct 13, 2020 · 7 comments
Open

Question regarding merging parsers #101

ThibautVerron opened this issue Oct 13, 2020 · 7 comments

Comments

@ThibautVerron
Copy link

Hi,

I'm trying to write a parser for LaTeX more, leveraging the built-in support by outline-minor-mode and tex-fold-mode.

So far I've been trying to integrate those parsers myself, but it looks like origami does have a lot of functions for tree manipulation.
Is there something which would allow to merge trees, shortening nodes if needed?

For instance, for a buffer:

begin type1
begin type2
begin type1
end type2
end type1
end type1

and a parser "type 1" making a tree

type 1 (line 1 to  6) 
    -- type 1 (line 3 to 5)

and a parser "type 2" making a tree

type 2 (line 2 to 4)

I'd like a resulting "merged" tree:

type 1 (line 1 to 6)
    -- type 2 (line 2 to 4)
        -- type 1 (line 3 to 4)

Is that already implemented, or should I carry on doing it by hand?

And more generally, what is the easiest way to test the functions in origami.el? For the parsers, I can get an idea of the structure of the tree by passing 'list as 'create, but it seems to break for the origami- functions, which I guess expect more structure out of 'create.

@ThibautVerron ThibautVerron changed the title Question regarding parsers Question regarding merging parsers Oct 13, 2020
@jcs090218
Copy link

You can open this in my branch here, https://github.com/jcs-elpa/origami.el.

See, #99.

@ThibautVerron
Copy link
Author

ThibautVerron commented Oct 27, 2020

Hi, thanks for your answer!

It took me a while to figure out what branch you meant... I guess you meant fork?

I have read about why this fork was created on Melpa but I'm afraid that separating issues between upstream and fork is only going to add to the confusion. Especially considering that this issue is really a question and not a bug report, I think it is better for it to be where more people will see it. Hopefully it will contribute to the goal of having a better documentation for parsers everywhere.

Are you by any chance familiar with the relevant part of the code?

@jcs090218
Copy link

It took me a while to figure out what branch you meant... I guess you meant fork?

Yes! Sorry for the confusion. I have changed my title to branch and fork!

I have read about why this fork was created on Melpa but I'm afraid that separating issues between upstream and fork is only going to add to the confusion. Especially considering that this issue is really a question and not a bug report, I think it is better for it to be where more people will see it. Hopefully it will contribute to the goal of having a better documentation for parsers everywhere.

Got it!

Are you by any chance familiar with the relevant part of the code?

Not really. I am reading the code now but in a very slow progress. As I mentioned in the thread here, elp-revive/origami.el#1. I am looking for people to co-maintain or further develop this package together. Mainly due to the author's lack of activity. Therefore, everything I am trying to do here is to keep this package alive. 👍

@jvasile
Copy link

jvasile commented Feb 21, 2021

Hello, I am interested in orgami-mode for Latex. I came here to get some hints on implementing it and found this issue. I don't particularly care whether this gets implemented in origami-mode or as a parser defined in my .emacs. @ThibautVerron have you made any progress? If your WIP is in a repo somewhere, drop a link and I'll take a look. Thanks!

@jcs090218
Copy link

jcs090218 commented Feb 22, 2021

Hi @jvasile,

If you are looking for merging multiple parsers then try my fork here. It allows you to merge multiple parsers to one parser by using function origami-fold-shallow-merge. From what I remember from this version of origami, it only accept merging 2 parsers.

If you are going to write your own parser for origami, then you should go check the file origami-parsers.el. My fork has more examples for you to reference it.

@ThibautVerron
Copy link
Author

ThibautVerron commented Feb 22, 2021

Hi @jvasile . No I have not made new progress since last time, but I would like to look at it again in the very near future.

I put the code I have so far on https://gitlab.com/thibaut.verron/latex-folding. As far as I remember it's far from working, but if @jcs090218's fork lets us merge parsers, it could be made to work without too much effort. I believe a lot of my problems were coming from the fact that I was trying to do the merge by hand.

Regarding the origami fork, my goal was to make a parser which returns begin and end folding points for any folding engine to use. As it turns out, at the moment origami is the only folding engine using such a parser, and it has facilities for merging trees, etc.

So the short term plan would be to have a parser working with origami. I don't think that the fork will break compatibility badly enough that origami parsers would stop working. In the longer run I guess I still want to merge the trees directly in the parser, in order to really have a parser working with any folding engine.

@jvasile
Copy link

jvasile commented Feb 22, 2021

Thanks for the pointers, @ThibautVerron. I'll take a look and keep an eye on @jcs090218's fork.

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

No branches or pull requests

3 participants