PrismJS / PrismJS/prism

Enforce consistent practices for greedy patterns

Open
#3,265 0 comments 1 reaction 1 assignee View on GitHub

@RunDevelopment is already working on this.

Since Dec 3, 2021.

enhancement language-definitions
Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

Motivation
Greedy matching is hard and interacts in non-obvious ways with non-greedy matching. This has caused issues in the past, like the one fixed in #2680.

One best practice for grammars containing both greedy and non-greedy tokens is to ensure that there are no non-greedy tokens before any greedy token. Let's call a grammar of that form a normalized grammar or grammar in normal form.

Normalized grammars are immune to the unintuitive interactions between greedy and non-greedy patterns. Hence, they are immune to a whole range of highlighting bugs. Unfortunately, a lot of our current languages do not follow this best practice.

Description
The goals of this issue are to:

  1. Find out whether every grammar can feasibly be brought into normal form.
  2. If yes, add automated tests that enforce normalized grammars.

These goals can be achieved incrementally. The first steps should be to find, fix, and test for specific patterns where grammars only slightly deviate from normal form.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.