Skip to content

[Suggestion]: Rearrange layers #57

@boltlessengineer

Description

@boltlessengineer

We can't just say "There will be parsers not following the spec eventually" and let them do what they want. That's exactly what happened to Markdown (every parser claims to support CommonMark & GFM. Which means they don't) and I hope Norg to be better than that.
Yes, there will be parsers not following the rules. But if they don't follow the rule, they should be defined as non-compliant parsers.
ー from #53 (comment)

Current 5 layers are overlapping each other in a very complex way. Many grammars are spread all over the 5 layers to satisfy expected use-cases of each layers. Linkables are introduced from layer 1 but finalized in layer 5.

Having generalized, extendable, simpler definition of layer system would be better.

If proper adaptation is easier, we will have less incomplete, dialect specs.

Background ideas:

v1 spec tried to include as much syntax as possible, but end up having massive inline grammar while still missing things like citations.

So new spec should better follow:

  • All layers should be extendable because we can't expect every use-cases.
  • Have less first-class syntax as possible. Generalize more with macros.

Rearranged layer system

  • Layer 1: only inline spec. But complete implementation of it. This even includes inline macros but doesn't force to implement same macro system using Janet.
  • Layer 2: all, complete syntax. Parser should be able to parse all grammars. Macro system is still not forced.
  • Layer 3: all complete syntax and janet-based macro system.
Syntax compatibility Macro system compatibility
Layer 1 Only inline spec No
Layer 2 Yes No
Layer 3 Yes Yes

Most implementations will safely fall to one of these three layers.

If they don't satisfy syntax compatibility, they are just different syntax.

If they don't implement macro system, it's fine. They still have place called "Layer 2".

With less, generalized syntax, we can make it easier to implement complete (or inline-complete) norg syntax. Resulting easier adoptaion. All hard parts are belonged to the macro system which can be packed as standard library.

Some ground works:

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