alecthomas / alecthomas/participle

bug: lexer codegen should validate token identifiers are valid

オープン
#202 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Go
スター
3.9k
フォーク
213
PR マージ指標
30日以内にマージされた PR はありません

説明

Hi,

I've been playing with Participle and I wanted to try to codegen feature, however the generated code seems to not escape some characters, leading to uncompilable source.

See the following example :

```golang
// ...
} else if match := match:(l.s, l.p); match[1] != 0 {
sym = -47
groups = match[:]
} else if match := match;(l.s, l.p); match[1] != 0 {
sym = -48
groups = match[:]
} else if match := match|(l.s, l.p); match[1] != 0 {
sym = -49
groups = match[:]
} else if match := match,(l.s, l.p); match[1] != 0 {
sym = -50
groups = match[:]
} else if match := match@(l.s, l.p); match[1] != 0 {
sym = -51
groups = match[:]
}
// ...
```

My rules used :

```golang
{
// ...
{":", `:`, nil},
{";", `;`, nil},
{"|", `\|`, nil},
{",", `,`, nil},
{"@", `@`, nil},
// ...
}
```

As far as I can tell it comes from https://github.com/alecthomas/participle/blob/master/lexer/codegen.go#L251

While I do agree that I could rename my Rule name to make the whole thing works, I think it might be a good idea to come up with some strategy in order to avoid this when generating code.

I'm fine with writting a PR if you have a idea for this.

Cheers !

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。