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

Use a PEG parser? #281

Open
gitonthescene opened this issue Jul 5, 2021 · 6 comments
Open

Use a PEG parser? #281

gitonthescene opened this issue Jul 5, 2021 · 6 comments

Comments

@gitonthescene
Copy link

gitonthescene commented Jul 5, 2021

Okay this is a more extreme idea. It’s probably worth bringing to the broader org community. (Maybe worg?)

[EDIT: FWIW, I tried to start a https://lists.gnu.org/archive/html/emacs-orgmode/2021-07/msg00355.html.]

If we had a better developed AST we’d have more direct access to things like SCHEDULE dates for integration with calendars or managing agendas, etc.

The actual org-mode parser is pretty permissive allowing things like skipping levels of headlines. There are projects out there which produce an AST with JavaScript which could be leveraged but necessarily make choices for parts of org made less explicit.

What if we had a stricter better defined syntax? This would make it easier to develop tools like MobileOrg that are more interoperable.

I’ve started working on a PEG representation for the org grammar. There are fairly active projects that implement PEG parsers which could then be used.

This is fairly bold proposal though and there are many angles from which to approach the discussion.

  • Could the “official grammar” be strict but the in emacs parser be more lax?
  • Could MobileOrg require the stricter grammar?
  • Could we use a PEG parser only for “broad strokes” parsing to suss out the structure? This might line up more with how org parser in emacs works

In any event, my sense is that this approach has fruit to bear but I’m unsure of where to take it and am looking for people to brainstorm with. If you have suggestions, please let me know.

org-mode-grammar.txt

@gitonthescene
Copy link
Author

gitonthescene commented Jul 5, 2021

Related, I propose to start a project of org file samples which cover all the possibilities of the grammar. The community could use it to demonstrate issues which could then be used by developers to run tests. There are some examples out there but none quite comprehensive.

[EDIT: I've started laying out some of the simplest examples.]

@gitonthescene
Copy link
Author

FWIW, here’s an overview from the author of Python. There is a relatively recent proposal to move Python to a PEG parser.

@gitonthescene
Copy link
Author

gitonthescene commented Jul 9, 2021

Or maybe just commit to this EBNF grammar. (I only just learned about it.) I’m assuming the GPL 3 license isn’t an issue.

@webframp
Copy link
Member

webframp commented Oct 1, 2021

Some very interesting ideas. I'd like to get more feedback from a broader audience for this kind of change, but It's great to think big

@webframp
Copy link
Member

Or maybe just commit to this EBNF grammar. (I only just learned about it.) I’m assuming the GPL 3 license isn’t an issue.

It's been years since I had to read EBNF but I like the ideas a lot. Currently the problems I have is prioritizing what to work on and finding time to do dev work.

@gitonthescene
Copy link
Author

I haven’t looked at this in a while but I do think that putting the parse tree on a firmer footing opens up possibilities for new features. For instance you could enable using the punch clock features of org-mode. Like I said above, I’m happy to brainstorm either here or on the chat.

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

2 participants