diff --git a/formatter/body.go b/formatter/body.go index 4bc2cc0..442b851 100644 --- a/formatter/body.go +++ b/formatter/body.go @@ -37,7 +37,7 @@ func (body) InnerStatement(prev, cur *element) (bool, statement) { return false, nil } -func (body) TypeOf() typeStatement { return tsNone } +func (body) TypeOf() typeStatement { return tsBody } func (b *body) IsEnd(prev, cur *element) (bool, bool) { if cur.Token.Type == nEnd { diff --git a/formatter/chain_statments.go b/formatter/chain_statments.go index 0f26076..1bbca6e 100644 --- a/formatter/chain_statments.go +++ b/formatter/chain_statments.go @@ -61,6 +61,10 @@ func (cs *chainStatments) ExctractStatement(ts typeStatement) statement { if cs.chain[i].TypeOf() == ts { item = i } + + if cs.chain[i].TypeOf() == tsBody { + break + } } if item == -1 { diff --git a/formatter/document.go b/formatter/document.go index dc2f09b..5daab97 100644 --- a/formatter/document.go +++ b/formatter/document.go @@ -44,6 +44,7 @@ const ( tsFuncCallStatement tsTable tsUnknow + tsBody ) // chunk ::= block