goodmami / goodmami/pe

Dispatch operator

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
51
Forks
4
PR merge metrics
No merged PRs in 30d

Description

Add an operator that computes the first character of each alternative of a Choice and then does an immediate jump when one is unambiguous.

E.g.,

```
A <- "abc" / [x-z] / E / .
E <- "e"
```

Could be a dispatch like:

```
'a' >> "abc"
'x' >> [x-z]
'y' >> [x-z]
'z' >> [x-z]
'e' >> E
else >> .
```

Some situations could get tricky, so this should back off to a regular ordered choice if it's not clear:

```
A <- "abc" / "d" / "aaa"
```

becomes

```
'd' >>> "d"
'a' >>> "abc" / "aaa"
```

This is basically computing "first sets". The Dispatch() operator function (or whatever it's called) would just be an optimization and wouldn't necessarily get PEG notation associated with it.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.