private String calculateFixedValue(ParserRuleContext requiredPattern) {
        return new UserAgentTreeWalkerBaseVisitor<String>() {

            @Override
            protected boolean shouldVisitNextChild(RuleNode node, String currentResult) {
                return currentResult == null;
            }

            @Override
            protected String aggregateResult(String aggregate, String nextResult) {
                return nextResult == null ? aggregate : nextResult;
            }

            // =================
            // Having a lookup that provides a fixed value yields an error as it complicates things needlessly
            @Override public String visitMatcherPathLookup(MatcherPathLookupContext ctx) {
                return visitLookupsFailOnFixedString(ctx.matcher());
            }

            @Override public String visitMatcherPathLookupContains(MatcherPathLookupContainsContext ctx) {
                return visitLookupsFailOnFixedString(ctx.matcher());
            }

            @Override public String visitMatcherPathLookupPrefix(MatcherPathLookupPrefixContext ctx) {
                return visitLookupsFailOnFixedString(ctx.matcher());
            }

            @Override public String visitMatcherPathIsInLookup(MatcherPathIsInLookupContext ctx) {
                return visitLookupsFailOnFixedString(ctx.matcher());
            }

            @Override public String visitMatcherPathIsInLookupContains(MatcherPathIsInLookupContainsContext ctx) {
                return visitLookupsFailOnFixedString(ctx.matcher());
            }

            @Override public String visitMatcherPathIsNotInLookupContains(MatcherPathIsNotInLookupContainsContext ctx) {
                return visitLookupsFailOnFixedString(ctx.matcher());
            }

            @Override public String visitMatcherPathIsInLookupPrefix(MatcherPathIsInLookupPrefixContext ctx) {
                return visitLookupsFailOnFixedString(ctx.matcher());
            }

            @Override public String visitMatcherPathIsNotInLookupPrefix(MatcherPathIsNotInLookupPrefixContext ctx) {
                return visitLookupsFailOnFixedString(ctx.matcher());
            }


            @SuppressWarnings("SameReturnValue")
            private String visitLookupsFailOnFixedString(ParseTree matcherTree) {
                String value = visit(matcherTree);
                if (value == null) {
                    return null;
                }
                // Now we know this is a fixed value lookup ... JUST DON'T as it is needless.
                throw new InvalidParserConfigurationException("A lookup for a fixed input value is a needless complexity.");
            }
            // =================

            @Override
            public String visitPathFixedValue(PathFixedValueContext ctx) {
                return ctx.value.getText();
            }
        }.visit(requiredPattern);
    }
@return The fixed value in case of a fixed value. NULL if a dynamic value
analyzer/src/main/java/nl/basjes/parse/useragent/analyze/treewalker/TreeExpressionEvaluator.java