alecthomas / alecthomas/participle

Proposal: Support grammar aliases.

Offen
#22 8 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
proposal
Vorherrschende Sprache
Go
Sterne
3.9k
Forks
213
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

In moderately complex grammars it's fairly common to see duplicate patterns emerge. For example, when matching a dot-separated identifier (eg. `foo.bar`) the pattern `(Ident { "." Ident })` is used repeatedly. This can be handled by a Go type alias implementing the `Parseable` interface, but that is quite onerous.

I propose adding support for grammar aliases. Here's an example creating and using an `Identifier` alias:

```go
type Assignment struct {
Name string `@Identifier=(Ident { "." Ident })`
Variable string `"=" @Identifier`
}
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.