@@ -8070,29 +8070,46 @@ func (p *Parser) parseAlterEndpointStatement() (*ast.AlterEndpointStatement, err
80708070 if p .curTok .Type == TokenEquals {
80718071 p .nextToken () // consume =
80728072 }
8073- opt := & ast.LiteralEndpointProtocolOption {}
8074- switch optName {
8075- case "LISTENER_PORT" :
8076- opt .Kind = "TcpListenerPort"
8077- case "LISTENER_IP" :
8078- opt .Kind = "TcpListenerIP"
8079- default :
8080- opt .Kind = optName
8081- }
8082- if p .curTok .Type == TokenNumber {
8083- opt .Value = & ast.IntegerLiteral {
8084- LiteralType : "Integer" ,
8085- Value : p .curTok .Literal ,
8073+ if optName == "LISTENER_IP" {
8074+ // Parse IP address option specially
8075+ ipOpt := & ast.ListenerIPEndpointProtocolOption {
8076+ Kind : "TcpListenerIP" ,
80868077 }
8087- p .nextToken ()
8088- } else if p .curTok .Type == TokenString {
8089- opt .Value = & ast.StringLiteral {
8090- LiteralType : "String" ,
8091- Value : p .curTok .Literal ,
8078+ // Check for ALL or IP address in parentheses
8079+ if strings .ToUpper (p .curTok .Literal ) == "ALL" {
8080+ ipOpt .IsAll = true
8081+ p .nextToken ()
8082+ } else if p .curTok .Type == TokenLParen {
8083+ p .nextToken () // consume (
8084+ ipOpt .IPv4PartOne = p .parseIPv4Address ()
8085+ if p .curTok .Type == TokenRParen {
8086+ p .nextToken () // consume )
8087+ }
80928088 }
8093- p .nextToken ()
8089+ stmt .ProtocolOptions = append (stmt .ProtocolOptions , ipOpt )
8090+ } else {
8091+ opt := & ast.LiteralEndpointProtocolOption {}
8092+ switch optName {
8093+ case "LISTENER_PORT" :
8094+ opt .Kind = "TcpListenerPort"
8095+ default :
8096+ opt .Kind = optName
8097+ }
8098+ if p .curTok .Type == TokenNumber {
8099+ opt .Value = & ast.IntegerLiteral {
8100+ LiteralType : "Integer" ,
8101+ Value : p .curTok .Literal ,
8102+ }
8103+ p .nextToken ()
8104+ } else if p .curTok .Type == TokenString {
8105+ opt .Value = & ast.StringLiteral {
8106+ LiteralType : "String" ,
8107+ Value : p .curTok .Literal ,
8108+ }
8109+ p .nextToken ()
8110+ }
8111+ stmt .ProtocolOptions = append (stmt .ProtocolOptions , opt )
80948112 }
8095- stmt .ProtocolOptions = append (stmt .ProtocolOptions , opt )
80968113 if p .curTok .Type == TokenComma {
80978114 p .nextToken ()
80988115 }
@@ -8250,6 +8267,66 @@ func (p *Parser) parseAlterEndpointStatement() (*ast.AlterEndpointStatement, err
82508267 return stmt , nil
82518268}
82528269
8270+ // parseIPv4Address parses an IPv4 address like "1.2.3.4" or "1 . 2 . 3 . 4"
8271+ // The lexer may tokenize "1.2" as a single float token, so we need to handle that
8272+ func (p * Parser ) parseIPv4Address () * ast.IPv4 {
8273+ ipv4 := & ast.IPv4 {}
8274+ var octets []string
8275+
8276+ // Collect all octets from tokens
8277+ for len (octets ) < 4 {
8278+ if p .curTok .Type == TokenNumber {
8279+ // Check if this is a float-like number containing dots
8280+ literal := p .curTok .Literal
8281+ if strings .Contains (literal , "." ) {
8282+ // Split by dots and add each part as an octet
8283+ parts := strings .Split (literal , "." )
8284+ for _ , part := range parts {
8285+ if part != "" && len (octets ) < 4 {
8286+ octets = append (octets , part )
8287+ }
8288+ }
8289+ } else {
8290+ octets = append (octets , literal )
8291+ }
8292+ p .nextToken ()
8293+ } else if p .curTok .Type == TokenDot {
8294+ // Skip standalone dots
8295+ p .nextToken ()
8296+ } else {
8297+ break
8298+ }
8299+ }
8300+
8301+ // Assign octets to the IPv4 struct
8302+ if len (octets ) >= 1 {
8303+ ipv4 .OctetOne = & ast.IntegerLiteral {
8304+ LiteralType : "Integer" ,
8305+ Value : octets [0 ],
8306+ }
8307+ }
8308+ if len (octets ) >= 2 {
8309+ ipv4 .OctetTwo = & ast.IntegerLiteral {
8310+ LiteralType : "Integer" ,
8311+ Value : octets [1 ],
8312+ }
8313+ }
8314+ if len (octets ) >= 3 {
8315+ ipv4 .OctetThree = & ast.IntegerLiteral {
8316+ LiteralType : "Integer" ,
8317+ Value : octets [2 ],
8318+ }
8319+ }
8320+ if len (octets ) >= 4 {
8321+ ipv4 .OctetFour = & ast.IntegerLiteral {
8322+ LiteralType : "Integer" ,
8323+ Value : octets [3 ],
8324+ }
8325+ }
8326+
8327+ return ipv4
8328+ }
8329+
82538330func (p * Parser ) parseAlterServiceStatement () (ast.Statement , error ) {
82548331 // Consume SERVICE
82558332 p .nextToken ()
0 commit comments