@@ -2505,11 +2505,59 @@ func (p *Parser) parseCreateProtoBundle(pos token.Pos) *ast.CreateProtoBundle {
2505
2505
2506
2506
func (p * Parser ) parseAlterProtoBundle (pos token.Pos ) * ast.AlterProtoBundle {
2507
2507
p .expect ("PROTO" )
2508
- p .expectKeywordLike ("BUNDLE" )
2509
- alteration := p .parseProtoBundleAlteration ()
2508
+ bundle := p .expectKeywordLike ("BUNDLE" ).Pos
2509
+ insert := p .tryParseAlterProtoBundleInsert ()
2510
+ update := p .tryParseAlterProtoBundleUpdate ()
2511
+ delete := p .tryParseAlterProtoBundleDelete ()
2512
+
2510
2513
return & ast.AlterProtoBundle {
2511
- Alter : pos ,
2512
- Alteration : alteration ,
2514
+ Alter : pos ,
2515
+ Bundle : bundle ,
2516
+ Insert : insert ,
2517
+ Update : update ,
2518
+ Delete : delete ,
2519
+ }
2520
+ }
2521
+
2522
+ func (p * Parser ) tryParseAlterProtoBundleInsert () * ast.AlterProtoBundleInsert {
2523
+ if ! p .Token .IsKeywordLike ("INSERT" ) {
2524
+ return nil
2525
+ }
2526
+
2527
+ pos := p .expectKeywordLike ("INSERT" ).Pos
2528
+ types := p .parseProtoBundleTypes ()
2529
+
2530
+ return & ast.AlterProtoBundleInsert {
2531
+ Insert : pos ,
2532
+ Types : types ,
2533
+ }
2534
+ }
2535
+
2536
+ func (p * Parser ) tryParseAlterProtoBundleUpdate () * ast.AlterProtoBundleUpdate {
2537
+ if ! p .Token .IsKeywordLike ("UPDATE" ) {
2538
+ return nil
2539
+ }
2540
+
2541
+ pos := p .expectKeywordLike ("UPDATE" ).Pos
2542
+ types := p .parseProtoBundleTypes ()
2543
+
2544
+ return & ast.AlterProtoBundleUpdate {
2545
+ Update : pos ,
2546
+ Types : types ,
2547
+ }
2548
+ }
2549
+
2550
+ func (p * Parser ) tryParseAlterProtoBundleDelete () * ast.AlterProtoBundleDelete {
2551
+ if ! p .Token .IsKeywordLike ("DELETE" ) {
2552
+ return nil
2553
+ }
2554
+
2555
+ pos := p .expectKeywordLike ("DELETE" ).Pos
2556
+ types := p .parseProtoBundleTypes ()
2557
+
2558
+ return & ast.AlterProtoBundleDelete {
2559
+ Delete : pos ,
2560
+ Types : types ,
2513
2561
}
2514
2562
}
2515
2563
@@ -4379,34 +4427,3 @@ func (p *Parser) parseRenameTable(pos token.Pos) *ast.RenameTable {
4379
4427
}
4380
4428
4381
4429
}
4382
-
4383
- func (p * Parser ) parseProtoBundleAlteration () ast.ProtoBundleAlteration {
4384
- switch {
4385
- case p .Token .IsKeywordLike ("INSERT" ):
4386
- insert := p .expectKeywordLike ("INSERT" ).Pos
4387
- types := p .parseProtoBundleTypes ()
4388
-
4389
- return & ast.AlterProtoBundleInsert {
4390
- Insert : insert ,
4391
- Types : types ,
4392
- }
4393
- case p .Token .IsKeywordLike ("UPDATE" ):
4394
- update := p .expectKeywordLike ("UPDATE" ).Pos
4395
- types := p .parseProtoBundleTypes ()
4396
-
4397
- return & ast.AlterProtoBundleUpdate {
4398
- Update : update ,
4399
- Types : types ,
4400
- }
4401
- case p .Token .IsKeywordLike ("DELETE" ):
4402
- delete := p .expectKeywordLike ("DELETE" ).Pos
4403
- types := p .parseProtoBundleTypes ()
4404
-
4405
- return & ast.AlterProtoBundleDelete {
4406
- Delete : delete ,
4407
- Types : types ,
4408
- }
4409
- default :
4410
- panic (p .errorfAtToken (& p .Token , `expected INSERT, UPDATE or DELETE, but: %v` , p .Token .AsString ))
4411
- }
4412
- }
0 commit comments