Skip to content

Ideas for future redesign #6

Open
@slevithan

Description

@slevithan
  • Update supported syntax to include features and escaping rules from JavaScript flag v (ES2024).
  • Rewrite on top of an AST (regexpp, regexp-tree, etc.).
  • Consider becoming a TextMate grammar, Tree-sitter grammar, or CodeMirror mode (see CodeMirror PCRE mode).
    • Potentially extract RegExr's highlighting/tooltips as a starting point.
  • Add more options to the options argument used by colorizeAll and colorizePattern:
    • flavor - Ex: 'JavaScript', 'EMCAScript' (for JavaScript without "web reality"), 'PCRE', 'XRegExp', 'Regex+'.
      • Default: 'JavaScript'.
      • Use the latest known version for the flavor if version is not provided.
    • version - Regex flavor version. Ex: JavaScript/ECMAScript: '3', '5', '2024'; PCRE: '8.45', '10.39'.
      • Default: 'latest'.
      • Throw if unexpected value or if flavor is not provided.
      • Potential implementation: By using e.g. 'JavaScript'+'2024', it sets of bunch of feature flags, and parsing code can check for the feature flags rather than flavor/version. New flavor versions can then just augment existing objects of feature flags.
    • format - Options: '...' (default), '/.../flags', and maybe others.
      • '/.../flags' allows:
        1. Applying flags (can change syntax rules).
        2. Highlighting invalid flags/combinations and duplicates.
        3. Changing syntax rules, independent of flags: Only need to escape / in regex literals. Note: ES5 included a change to allow unescaped [/] in regex literals.
      • Throw if both format and flags are provided.
    • warningsOn - On by default? Ex: || at top level, range overflow, quantified lookaround, incomplete tokens \c,\x,\u.
    • compatibilityOn - For differences in behavior for the same syntax across regex flavors (not for when some flavors don't support a feature). Ex: Empty char classes [], [^] (JS), leading unescaped ] in char classes (non-JS).
    • suggestionsOn - Ex: Use of octals, escaped literals, [0-9]\d (for flavors where \d is ASCII only), [\S\s] → dot with /s (if /s is active or no existing dots).
  • Render whitespace characters.
  • Add replacement text highlighting (also accepts options argument, with flavor, version, format).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions