tokenBracketPos

Returns index of closing/openinig bracket of the provided bracket

forward if true, then the search is in forward direction, i.e, the closing bracket is searched for tokens is the array of tokens to search in index is the index of the opposite bracket

It only works correctly if the brackets are in correct order, and the closing bracket is present so, before calling this, compiler.misc.checkBrackets should be called

package
uinteger
tokenBracketPos
(
bool forward = true
)
(,
uinteger index
)

Examples

st{
	Token[] tokens;
	tokens = [
		Token(Token.Type.Comma, ","), Token(Token.Type.BlockStart,"{"), Token(Token.Type.Comma,","),
		Token(Token.Type.IndexBracketOpen,"["),Token(Token.Type.IndexBracketClose,"]"),Token(Token.Type.BlockEnd,"}")
	];
	assert(tokens.tokenBracketPos!true(1) == 5);
	assert(tokens.tokenBracketPos!false(5) == 1);
	assert(tokens.tokenBracketPos!true(3) == 4);
	assert(tokens.tokenBracketPos!false(4) == 3

Meta