MobileOrg / mobileorg

MobileOrg iPhone App
http://mobileorg.github.io
GNU General Public License v2.0
557 stars 70 forks source link

Use a PEG parser? #281

Open gitonthescene opened 3 years ago

gitonthescene commented 3 years ago

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.

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 commented 3 years ago

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 commented 3 years ago

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

gitonthescene commented 3 years ago

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 commented 2 years ago

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 commented 10 months ago

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 commented 10 months ago

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.