private Item phraseBody(String indexName) {
        boolean quoted = false;
        CompositeItem composite = null;
        Item firstWord = null;
        boolean starAfterFirst = false;
        boolean starBeforeFirst;

        if (tokens.skipMultiple(QUOTE)) {
            quoted = !quoted;
        }
        boolean addStartOfHostMarker = addStartMarking();

        braceLevelURL = 0;

        do {
            starBeforeFirst = tokens.skip(STAR);

            if (tokens.skipMultiple(QUOTE)) {
                quoted = !quoted;
            }

            Item word = phraseWord(indexName, quoted, (firstWord != null) || (composite != null));

            if (word == null) {
                if (tokens.skipMultiple(QUOTE)) {
                    quoted = !quoted;
                }
                if (quoted && tokens.hasNext()) {
                    tokens.skipNoIgnore();
                    continue;
                } else {
                    break;
                }
            } else if (quoted && word instanceof PhraseSegmentItem) {
                ((PhraseSegmentItem) word).setExplicit(true);
            }

            if (composite != null) {
                composite.addItem(word);
                connectLastTermsIn(composite);
            } else if (firstWord != null) {
                if (submodes.site || submodes.url) {
                    UriItem uriItem = new UriItem();
                    if (submodes.site)
                        uriItem.setEndAnchorDefault(true);
                    composite = uriItem;
                }
                else {
                    if (quoted || indexFacts.getIndex(indexName).getPhraseSegmenting())
                        composite = new PhraseItem();
                    else
                        composite = new AndItem();
                }

                if ( (quoted || submodes.site || submodes.url) && composite instanceof PhraseItem) {
                    ((PhraseItem)composite).setExplicit(true);
                }
                if (addStartOfHostMarker) {
                    composite.addItem(MarkerWordItem.createStartOfHost());
                }
                if (firstWord instanceof IntItem asInt) {
                    firstWord = new WordItem(asInt.stringValue(), asInt.getIndexName(),
                                             true, asInt.getOrigin());
                }
                composite.addItem(firstWord);
                composite.addItem(word);
                connectLastTermsIn(composite);
            } else if (word instanceof PhraseItem) {
                composite = (PhraseItem)word;
            } else {
                firstWord = word;
                starAfterFirst = tokens.skipNoIgnore(STAR);
            }
            if (!quoted && tokens.currentIs(QUOTE)) {
                break;
            }

            boolean atWord = skipToNextPhraseWord(quoted);

            if (!atWord && tokens.skipMultipleNoIgnore(QUOTE)) {
                quoted = !quoted;
            }

            if (!atWord && !quoted) {
                break;
            }

            if (quoted && tokens.skipMultiple(QUOTE)) {
                break;
            }

        } while (tokens.hasNext());

        braceLevelURL = 0;

        if (composite != null) {
            if (addEndMarking()) {
                composite.addItem(MarkerWordItem.createEndOfHost());
            }
            return composite;
        } else if (firstWord != null && submodes.site) {
            if (starAfterFirst && !addStartOfHostMarker) {
                return firstWord;
            } else {
                composite = new PhraseItem();
                ((PhraseItem)composite).setExplicit(true);
                if (addStartOfHostMarker) {
                    composite.addItem(MarkerWordItem.createStartOfHost());
                }
                if (firstWord instanceof IntItem asInt) {
                    firstWord = new WordItem(asInt.stringValue(), asInt.getIndexName(), true, asInt.getOrigin());
                }
                composite.addItem(firstWord);
                if (!starAfterFirst) {
                    composite.addItem(MarkerWordItem.createEndOfHost());
                }
                return composite;
            }
        } else {
            if (firstWord != null && firstWord instanceof TermItem firstTerm && (starAfterFirst || starBeforeFirst)) {
                // prefix, suffix or substring
                if (starAfterFirst) {
                    if (starBeforeFirst) {
                        return new SubstringItem(firstTerm.stringValue(), true);
                    } else {
                        return new PrefixItem(firstTerm.stringValue(), true);
                    }
                } else {
                    return new SuffixItem(firstTerm.stringValue(), true);
                }
            }
            return firstWord;
        }
    }
Returns a word, a phrase, or another composite
container-search/src/main/java/com/yahoo/prelude/query/parser/StructuredParser.java