private void fencePairedParentheses(Token parentToken, List<FlowToken> tokens) throws SnuggleParseException {
        FlowToken token;
        LEFT_SEARCH: for (int i=0; i<tokens.size(); i++) { /* (List may change from 'i' onwards during loop) */
            token = tokens.get(i);
            
            /* Is this a \left? If so, work out where its balancing \right is and
             * wrap inside a fake environment. We'll also make sure we don't find a 
             * \right before a left!
             */
            if (token.isCommand(CorePackageDefinitions.CMD_RIGHT)) {
                /* Error: \right had not preceding \left */
                tokens.set(i, createError(token, CoreErrorCode.TFEM03));
                continue LEFT_SEARCH;
            }
            else if (token.isCommand(CorePackageDefinitions.CMD_LEFT)) {
                /* Now search forward for matching \right */
                List<FlowToken> innerTokens = new ArrayList<FlowToken>();
                CommandToken openBracketToken = (CommandToken) token;
                CommandToken matchingCloseBracketToken = null;
                int matchingCloseBracketIndex = -1;
                int bracketLevel = 1;
                FlowToken innerToken;
                MATCH_SEARCH: for (int j=i+1; j<tokens.size(); j++) { /* 'j' is search index from current point onwards */
                    innerToken = tokens.get(j);
                    if (innerToken.isCommand(CorePackageDefinitions.CMD_LEFT)) {
                        bracketLevel++;
                    }
                    else if (innerToken.isCommand(CorePackageDefinitions.CMD_RIGHT)) {
                        bracketLevel--;
                        if (bracketLevel==0) {
                            /* We've found the matcher */
                            matchingCloseBracketToken = (CommandToken) innerToken;
                            matchingCloseBracketIndex = j;
                            break MATCH_SEARCH;
                        }
                    }
                    innerTokens.add(innerToken);
                }
                if (matchingCloseBracketToken==null) {
                    /* Error: We never found a match for \\left so we'll kill the whole expression off */
                    tokens.set(i, createError(token, CoreErrorCode.TFEM04));
                    tokens.subList(i+1, tokens.size()).clear();
                    break LEFT_SEARCH;
                }
                /* Now replace this bracket with a fence */
                FrozenSlice replacementSlice = openBracketToken.getSlice().rightOuterSpan(matchingCloseBracketToken.getSlice());
                EnvironmentToken replacementToken = new EnvironmentToken(replacementSlice,
                        LaTeXMode.MATH,
                        CorePackageDefinitions.ENV_BRACKETED,
                        null,
                        new ArgumentContainerToken[] {
                            ArgumentContainerToken.createFromSingleToken(LaTeXMode.MATH, openBracketToken.getCombinerTarget()),
                            ArgumentContainerToken.createFromSingleToken(LaTeXMode.MATH, matchingCloseBracketToken.getCombinerTarget())
                        },
                        ArgumentContainerToken.createFromContiguousTokens(parentToken, LaTeXMode.MATH, innerTokens)
                );
                tokens.set(i, replacementToken);
                tokens.subList(i+1, matchingCloseBracketIndex+1).clear();
                continue LEFT_SEARCH;
            }
        }
    }