import { State , Token , createQueryState } from './token' ; export class GroupToken extends Token { tokens : Token [ ] ; open : string ; close : string ; constructor ( tokens , open = '(' , close = ')' ) { super ( ) ; this . open = open ; this . close = close ; this . tokens = tokens ; } reduce ( state , numberOfParameters ) { const tokensState = createQueryState ( this . tokens , numberOfParameters ) ; state . parameters . push ( ... tokensState . parameters ) ; const index = tokensState . text . length - 1 ; if ( index >= 0 ) { tokensState . text [ 0 ] = `${ this . open }${ tokensState . text [ 0 ] }` ; tokensState . text [ tokensState . text . length - 1 ] = `${ tokensState . text [ tokensState . text . length - 1 ] }${ this . close }` ; } else { } state . text . push ( ... tokensState . text ) ; return state ; } }