Skip to content

Commit df84451

Browse files
lvan100lianghuan
authored andcommitted
111
1 parent 32266e9 commit df84451

File tree

5 files changed

+315
-512
lines changed

5 files changed

+315
-512
lines changed

lib/httpidl/TParser.g4

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ embed_type_field
7575

7676
// Common field: type + name + optional annotations
7777
common_type_field
78-
: (KW_REQUIRED|KW_OPTIONAL)? common_field_type IDENTIFIER type_annotations?
79-
;
80-
81-
// Field type options
82-
common_field_type
83-
: base_type | user_type | container_type | TYPE_BYTES
78+
: (KW_REQUIRED|KW_OPTIONAL)? value_type IDENTIFIER type_annotations?
8479
;
8580

8681
// --------------------
@@ -174,7 +169,7 @@ list_type
174169

175170
// Allowed list/map value types
176171
value_type
177-
: base_type | user_type | container_type
172+
: base_type | user_type | container_type | TYPE_BYTES
178173
;
179174

180175
// --------------------

lib/httpidl/parser.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ func (l *ParseTreeListener) ExitOneof_def(ctx *Oneof_defContext) {
646646

647647
// parseCommonTypeField parses a regular field (not embedded) inside a type or oneof.
648648
func (l *ParseTreeListener) parseCommonTypeField(f ICommon_type_fieldContext, typeField *TypeField, t *Type) {
649-
typeField.Type = l.parseCommonFieldType(f.Common_field_type(), t)
649+
typeField.Type = l.parseValueType(f.Value_type(), t)
650650
typeField.Name = f.IDENTIFIER().GetText()
651651
typeField.Required = f.KW_REQUIRED() != nil
652652

@@ -796,23 +796,13 @@ func collectValidateFuncs(fieldType string, expr validate.Expr, funcs map[string
796796
}
797797
}
798798

799-
// parseCommonFieldType distinguishes between built-in, user-defined, or container types.
800-
func (l *ParseTreeListener) parseCommonFieldType(ctx ICommon_field_typeContext, t *Type) TypeDefinition {
799+
// parseValueType resolves value types inside container types.
800+
func (l *ParseTreeListener) parseValueType(ctx IValue_typeContext, t *Type) TypeDefinition {
801+
802+
// Built-in bytes type
801803
if ctx.TYPE_BYTES() != nil {
802804
return BytesType{}
803805
}
804-
return l.parseValueType(ctx, t)
805-
}
806-
807-
// parseValueType resolves value types inside container types.
808-
func (l *ParseTreeListener) parseValueType(ctx interface {
809-
GetText() string
810-
GetStart() antlr.Token
811-
GetStop() antlr.Token
812-
Base_type() IBase_typeContext
813-
User_type() IUser_typeContext
814-
Container_type() IContainer_typeContext
815-
}, t *Type) TypeDefinition {
816806

817807
// Built-in primitive type
818808
if b := ctx.Base_type(); b != nil {

0 commit comments

Comments
 (0)