Skip to content

Use a PEG parser? #281

@gitonthescene

Description

@gitonthescene

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions