alecthomas / alecthomas/participle

Failing to parse "//" while trying to parse comments

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

Beschreibung

Hi, I'm trying to parse proto files, but I want to preserve the comments inside the file. I'm starting with just adding
```
type Comment struct {
Pos lexer.Position

Message string `@("//" | "#" ) @Ident`
}
```

to the proto example in _examples.

but with a file like this
```
syntax = "proto3";

package com.book;

#testcomment
//testcomment2

message Book {
int64 isbn = 1;
string title = 2;
string author = 3;
}
```

it will successfully read the "#" line, but competely skip the "//" comment line. Am i doing something wrong?
the ENBF generated by the parser contains this, but I'm not super familiar with ENBF.
```
Comment = ("//" | "#") .
```

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.