| 24 | } |
| 25 | |
| 26 | func (self *structParser) Run(fd *model.FieldDescriptor, callback func(string, string) bool) (ok bool) { |
| 27 | |
| 28 | defer golexer.ErrorCatcher(func(err error) { |
| 29 | |
| 30 | log.Errorf("%s, '%s' '%v'", i18n.String(i18n.StructParser_LexerError), fd.Name, err.Error()) |
| 31 | }) |
| 32 | |
| 33 | self.NextToken() |
| 34 | |
| 35 | for self.TokenID() != Token_EOF { |
| 36 | |
| 37 | if self.TokenID() != Token_Identifier { |
| 38 | log.Errorf("%s, '%s'", i18n.String(i18n.StructParser_ExpectField), fd.Name) |
| 39 | return false |
| 40 | } |
| 41 | |
| 42 | key := self.TokenValue() |
| 43 | |
| 44 | self.NextToken() |
| 45 | |
| 46 | if self.TokenID() != Token_Comma { |
| 47 | log.Errorf("%s, '%s'", i18n.String(i18n.StructParser_UnexpectedSpliter), key) |
| 48 | return false |
| 49 | } |
| 50 | |
| 51 | self.NextToken() |
| 52 | |
| 53 | value := self.TokenValue() |
| 54 | |
| 55 | if !callback(key, value) { |
| 56 | return false |
| 57 | } |
| 58 | |
| 59 | self.NextToken() |
| 60 | |
| 61 | } |
| 62 | |
| 63 | return true |
| 64 | } |
| 65 | |
| 66 | func newStructParser(value string) *structParser { |
| 67 | l := golexer.NewLexer() |