Skip to content

Quantifiers add unnecessary non-capturing group #70

Closed
@trezy

Description

@trezy

Describe the bug
When using some of ... with symbols, a non-capturing group is added unconditionally. This is unnecessary for most individual symbols (e.g. <word>).

To Reproduce
Steps to reproduce the behavior:

  1. Open the Melody Playground
  2. Write a program which only uses some of ... with a single symbol, e.g.:
    some of <word>;
    
  3. Review the output

Expected behavior
RegEx output should only add wrap things with non-capturing groups if necessary or if implicitly required (via match {}).

Examples

any of <word>;
// Outputs /(?:\w)*/

any of "a";
// Outputs /a*/

some of <word>;
// Outputs /(?:\w)+/

some of "a";
// Outputs /a+/

option of <word>;
// Outputs /(?:\w)?/

option of "a";
// Outputs /a?/

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompilerRelated to the Melody compiler

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions