This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
forked from emicklei/proto
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ernest Micklei
authored and
Ernest Micklei
committed
Feb 2, 2017
1 parent
01d521f
commit 38c556f
Showing
9 changed files
with
103 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package proto | ||
|
||
// Group represents a (proto2 only) group. | ||
// https://developers.google.com/protocol-buffers/docs/reference/proto2-spec#group_field | ||
type Group struct { | ||
Name string | ||
Sequence int | ||
Elements []Visitee | ||
} | ||
|
||
// Accept dispatches the call to the visitor. | ||
func (g *Group) Accept(v Visitor) { | ||
v.VisitGroup(g) | ||
} | ||
|
||
// addElement is part of elementContainer | ||
func (g *Group) addElement(v Visitee) { | ||
g.Elements = append(g.Elements, v) | ||
} | ||
|
||
// parse expects: | ||
// group = label "group" groupName "=" fieldNumber messageBody | ||
func (g *Group) parse(p *Parser) error { | ||
tok, lit := p.scanIgnoreWhitespace() | ||
if tok != tIDENT { | ||
if !isKeyword(tok) { | ||
return p.unexpected(lit, "group name", g) | ||
} | ||
} | ||
g.Name = lit | ||
tok, lit = p.scanIgnoreWhitespace() | ||
if tok != tEQUALS { | ||
return p.unexpected(lit, "group =", g) | ||
} | ||
i, err := p.s.scanInteger() | ||
if err != nil { | ||
return p.unexpected(lit, "group sequence number", g) | ||
} | ||
g.Sequence = i | ||
parseMessageBody(p, g) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters