Java Code Examples for org.antlr.runtime.tree.CommonTree#getChildCount()

The following examples show how to use org.antlr.runtime.tree.CommonTree#getChildCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VersionNumberParser.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Parse a version and get the major or minor value
 *
 * @param tree
 *            the AST node of the version
 * @param unused
 *            unused
 * @return the version value as a {@link Long}
 * @throws ParseException
 *             the AST is malformed
 */
@Override
public Long parse(CommonTree tree, ICommonTreeParserParameter unused) throws ParseException {

    CommonTree firstChild = (CommonTree) tree.getChild(0);

    if (isUnaryInteger(firstChild)) {
        if (tree.getChildCount() > 1) {
            throw new ParseException(ERROR);
        }
        long version = UnaryIntegerParser.INSTANCE.parse(firstChild, null);
        if (version < 0) {
            throw new ParseException(ERROR);
        }
        return version;
    }
    throw new ParseException(ERROR);
}
 
Example 2
Source File: BasicSemanticChecks.java    From codebuff with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 Make sure that action is last element in outer alt; here action,
 a2, z, and zz are bad, but a3 is ok:
 (RULE A (BLOCK (ALT {action} 'a')))
 (RULE B (BLOCK (ALT (BLOCK (ALT {a2} 'x') (ALT 'y')) {a3})))
 (RULE C (BLOCK (ALT 'd' {z}) (ALT 'e' {zz})))
 */
protected void checkElementIsOuterMostInSingleAlt(GrammarAST tree) {
	CommonTree alt = tree.parent;
	CommonTree blk = alt.parent;
	boolean outerMostAlt = blk.parent.getType() == RULE;
	Tree rule = tree.getAncestor(RULE);
	String fileName = tree.getToken().getInputStream().getSourceName();
	if ( !outerMostAlt || blk.getChildCount()>1 )
	{
		ErrorType e = ErrorType.LEXER_COMMAND_PLACEMENT_ISSUE;
		g.tool.errMgr.grammarError(e,
								   fileName,
								   tree.getToken(),
								   rule.getChild(0).getText());

	}
}
 
Example 3
Source File: TestAstValidator.java    From spork with Apache License 2.0 6 votes vote down vote up
private void validateDataTypePresent(CommonTree tree) {
    if( tree != null ) {
        if( tree.getText().equals( "TUPLE_DEF" ) ) {
            for ( int i = 0; i < tree.getChildCount(); i++ ) {
                CommonTree child = (CommonTree)tree.getChild( i ); // FIELD node
                Assert.assertTrue( "FIELD_DEF".equals( child.getText() ) );
                CommonTree datatype = (CommonTree)child.getChild( 1 );
                Assert.assertTrue( datatype != null );
                String typeName = datatype.getText();
                Assert.assertTrue( !typeName.isEmpty() );
                validateDataTypePresent( child );
            }
        } else {
            for ( int i = 0; i < tree.getChildCount(); i++ ) {
                validateDataTypePresent( (CommonTree)tree.getChild( i ) );
            }
        }
    }
}
 
Example 4
Source File: UUIDParser.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Parse a UUID String and get a {@link UUID} in return.
 *
 * @param tree
 *            the UUID AST
 * @param unused
 *            unused
 * @return a {@link UUID}
 * @throws ParseException
 *             the AST was malformed
 */
@Override
public UUID parse(CommonTree tree, ICommonTreeParserParameter unused) throws ParseException {

    CommonTree firstChild = (CommonTree) tree.getChild(0);

    if (isAnyUnaryString(firstChild)) {
        if (tree.getChildCount() > 1) {
            throw new ParseException(INVALID_VALUE_FOR_UUID);
        }

        String uuidstr = UnaryStringParser.INSTANCE.parse(firstChild, null);

        try {
            return UUID.fromString(uuidstr);
        } catch (IllegalArgumentException e) {
            throw new ParseException(INVALID_FORMAT_FOR_UUID, e);
        }
    }
    throw new ParseException(INVALID_VALUE_FOR_UUID);
}
 
Example 5
Source File: EventIDParser.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Long parse(CommonTree tree, ICommonTreeParserParameter param) throws ParseException {

    CommonTree firstChild = (CommonTree) tree.getChild(0);

    if (isUnaryInteger(firstChild)) {
        if (tree.getChildCount() > 1) {
            throw new ParseException(INVALID_VALUE_ERROR);
        }
        long intval = UnaryIntegerParser.INSTANCE.parse(firstChild, null);
        if (intval > Integer.MAX_VALUE) {
            throw new ParseException("Event id larger than int.maxvalue, something is amiss"); //$NON-NLS-1$
        }
        return intval;
    }
    throw new ParseException(INVALID_VALUE_ERROR);
}
 
Example 6
Source File: SizeParser.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Gets the value of a "size" integer attribute.
 *
 * @param rightNode
 *            A CTF_RIGHT node.
 * @param param
 *            unused
 * @return The "size" value. Can be 4 bytes.
 * @throws ParseException
 *             if the size is not an int or a negative
 */
@Override
public Long parse(CommonTree rightNode, ICommonTreeParserParameter param) throws ParseException {
    CommonTree firstChild = (CommonTree) rightNode.getChild(0);
    if (isUnaryInteger(firstChild)) {
        if (rightNode.getChildCount() > 1) {
            throw new ParseException(INVALID_VALUE_FOR_SIZE);
        }
        long size = UnaryIntegerParser.INSTANCE.parse(firstChild, null);
        if (size < 1) {
            throw new ParseException(INVALID_VALUE_FOR_SIZE);
        }
        return size;
    }
    throw new ParseException(INVALID_VALUE_FOR_SIZE);
}
 
Example 7
Source File: AlignmentParser.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Gets the value of a "align" integer or struct attribute.
 * @param tree
 *            A CTF_RIGHT node or directly an unary integer.
 *
 * @return The align value.
 * @throws ParseException
 *             Invalid alignment value
 */
@Override
public Long parse(CommonTree tree, ICommonTreeParserParameter param) throws ParseException {
    /*
     * If a CTF_RIGHT node was passed, call getAlignment with the first
     * child
     */
    if (tree.getType() == CTFParser.CTF_RIGHT) {
        if (tree.getChildCount() > 1) {
            throw new ParseException(INVALID_VALUE_FOR_ALIGNMENT);
        }

        return parse((CommonTree) tree.getChild(0), param);
    } else if (isUnaryInteger(tree)) {
        long alignment = UnaryIntegerParser.INSTANCE.parse(tree, null);

        if (!isValidAlignment(alignment)) {
            throw new ParseException(INVALID_VALUE_FOR_ALIGNMENT + " : " //$NON-NLS-1$
                    + alignment);
        }

        return alignment;
    }
    throw new ParseException(INVALID_VALUE_FOR_ALIGNMENT); // $NON-NLS-1$
}
 
Example 8
Source File: AbstractHiveQLProcessor.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void findTableNames(final Object obj, final Set<TableName> tableNames) {
    if (!(obj instanceof CommonTree)) {
        return;
    }
    final CommonTree tree = (CommonTree) obj;
    final int childCount = tree.getChildCount();
    if ("TOK_TABNAME".equals(tree.getText())) {
        final TableName tableName;
        final boolean isInput = "TOK_TABREF".equals(tree.getParent().getText());
        switch (childCount) {
            case 1 :
                tableName = new TableName(null, tree.getChild(0).getText(), isInput);
                break;
            case 2:
                tableName = new TableName(tree.getChild(0).getText(), tree.getChild(1).getText(), isInput);
                break;
            default:
                throw new IllegalStateException("TOK_TABNAME does not have expected children, childCount=" + childCount);
        }
        // If parent is TOK_TABREF, then it is an input table.
        tableNames.add(tableName);
        return;
    }
    for (int i = 0; i < childCount; i++) {
        findTableNames(tree.getChild(i), tableNames);
    }
}
 
Example 9
Source File: FTSQueryParser.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static boolean isStarWithNoField(CommonTree testNode)
{
    if (testNode.getType() == FTSParser.TERM && testNode.getChildCount() == 1)
    {
        CommonTree child = (CommonTree) testNode.getChild(0);
        if (child.getType() == FTSParser.STAR)
        {
            return true;
        }
    }
    return false;
}
 
Example 10
Source File: FTSQueryParser.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
static private CommonTree copy(CommonTree source)
{
    CommonTree newNode = new CommonTree(source);
    if (source.getChildCount() > 0)
    {
        for (Object current : source.getChildren())
        {
            CommonTree child = (CommonTree) current;
            CommonTree newChild = copy(child);
            newNode.addChild(newChild);
        }
    }
    return newNode;
}
 
Example 11
Source File: FTSQueryParser.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static boolean isAutoPhrasable(CommonTree node, boolean defaultConjunction) {
	if((node.getType() == FTSParser.CONJUNCTION) && (node.getChildCount() > 1))
	{
		int simpleTermCount = 0;
		for (Object current : node.getChildren())
		{
			CommonTree child = (CommonTree) current;
			if((child.getType() ==  FTSParser.MANDATORY) || (child.getType() ==  FTSParser.DEFAULT))
			{
				if(child.getChildCount() > 0)
				{
					CommonTree item = (CommonTree)child.getChild(0);
					if((item.getType() == FTSParser.TERM) && (item.getChildCount() == 1))
					{
						simpleTermCount++;
					}
				}
			}
			else
			{
				return false;
			}
		}
		return simpleTermCount > 1;
	}

	return false;

}
 
Example 12
Source File: TreePrinter.java    From spork with Apache License 2.0 5 votes vote down vote up
public static void printTree(CommonTree tree, int indent) {
    if( tree != null ) {
        StringBuilder sb = new StringBuilder();
        for ( int i = 0; i < indent; i++ )
            sb = sb.append( "   " );

        System.out.println( sb + tree.getText() );

        for ( int i = 0; i < tree.getChildCount(); i++ ) {
            printTree( (CommonTree)tree.getChild( i ), indent + 1 );
        }
    }
}
 
Example 13
Source File: QueryTreeTransformer.java    From cuba with Apache License 2.0 5 votes vote down vote up
public void mixinJoinIntoTree(CommonTree joinClause, EntityVariable entityReference, boolean renameVariable) {
    CommonTree from = queryTree.getAstFromNode();
    for (int i = 0; i < from.getChildCount(); i++) {
        SelectionSourceNode selectionSource = (SelectionSourceNode) from.getChild(i);
        if (selectionSource.getChild(0) instanceof IdentificationVariableNode) {
            IdentificationVariableNode identificationVariable = (IdentificationVariableNode) selectionSource.getChild(0);
            if (entityReference.supportsJoinTo(identificationVariable)) {
                String variableName = identificationVariable.getVariableName();
                if (!(joinClause instanceof JoinVariableNode)) {
                    throw new RuntimeException("Passed joinClause is not JoinVariableNode: " + joinClause.getClass());
                }

                JoinVariableNode joinNode = (JoinVariableNode) joinClause;

                if (hasJoinNode(joinNode, selectionSource)) {
                    return;
                }

                if (renameVariable) {
                    PathNode path = joinNode.findPathNode();
                    if (path != null) {
                        path.renameVariableTo(variableName);
                    }
                }

                selectionSource.addChild(joinClause);
                from.freshenParentAndChildIndexes();
                return;
            }
        }
    }
    throw new RuntimeException("Join mixing failed. Cannot find selected entity with name " + entityReference);
}
 
Example 14
Source File: StreamIdParser.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Parses a stream id
 *
 * @param tree
 *            the AST node with "id = N;"
 * @return the value of the stream as a {@link Long}
 */
@Override
public Long parse(CommonTree tree, ICommonTreeParserParameter param) throws ParseException {
    CommonTree firstChild = (CommonTree) tree.getChild(0);
    if (isUnaryInteger(firstChild)) {
        if (tree.getChildCount() > 1) {
            throw new ParseException("invalid value for stream id"); //$NON-NLS-1$
        }
        long intval = UnaryIntegerParser.INSTANCE.parse(firstChild, null);
        return intval;
    }
    throw new ParseException("invalid value for stream id"); //$NON-NLS-1$
}
 
Example 15
Source File: SignedParser.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Parses whether the parent is signed or not. Typical syntax would be
 * "signed = true;" or "signed = false;"
 *
 * @param tree
 *            the AST node containing "signed = boolean;"
 * @param unused
 *            unused
 * @return @link {@link Boolean#TRUE} if signed, {@link Boolean#FALSE} if
 *         unsigned
 * @throws ParseException
 *             on a malformed tree
 */
@Override
public Boolean parse(CommonTree tree, ICommonTreeParserParameter unused) throws ParseException {
    boolean ret = false;
    CommonTree firstChild = (CommonTree) tree.getChild(0);

    if (isUnaryString(firstChild)) {
        String strval = concatenateUnaryStrings(tree.getChildren());

        if (strval.equals(MetadataStrings.TRUE)
                || strval.equals(MetadataStrings.TRUE2)) {
            ret = true;
        } else if (strval.equals(MetadataStrings.FALSE)
                || strval.equals(MetadataStrings.FALSE2)) {
            ret = false;
        } else {
            throw new ParseException(INVALID_BOOLEAN_VALUE
                    + firstChild.getChild(0).getText());
        }
    } else if (isUnaryInteger(firstChild)) {
        /* Happens if the value is something like "1234.hello" */
        if (tree.getChildCount() > 1) {
            throw new ParseException(INVALID_BOOLEAN_VALUE);
        }

        long intval = UnaryIntegerParser.INSTANCE.parse(firstChild, null);

        if (intval == 1) {
            ret = true;
        } else if (intval == 0) {
            ret = false;
        } else {
            throw new ParseException(INVALID_BOOLEAN_VALUE
                    + firstChild.getChild(0).getText());
        }
    } else {
        throw new ParseException(INVALID_BOOLEAN_VALUE);
    }
    return ret;
}
 
Example 16
Source File: AbstractHive3QLProcessor.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void findTableNames(final Object obj, final Set<TableName> tableNames) {
    if (!(obj instanceof CommonTree)) {
        return;
    }
    final CommonTree tree = (CommonTree) obj;
    final int childCount = tree.getChildCount();
    if ("TOK_TABNAME".equals(tree.getText())) {
        final TableName tableName;
        final boolean isInput = "TOK_TABREF".equals(tree.getParent().getText());
        switch (childCount) {
            case 1 :
                tableName = new TableName(null, tree.getChild(0).getText(), isInput);
                break;
            case 2:
                tableName = new TableName(tree.getChild(0).getText(), tree.getChild(1).getText(), isInput);
                break;
            default:
                throw new IllegalStateException("TOK_TABNAME does not have expected children, childCount=" + childCount);
        }
        // If parent is TOK_TABREF, then it is an input table.
        tableNames.add(tableName);
        return;
    }
    for (int i = 0; i < childCount; i++) {
        findTableNames(tree.getChild(i), tableNames);
    }
}
 
Example 17
Source File: RecognizedParamsExtractor.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Gets the clause specificed in paramName
 *
 * @param param
 * @param paramName
 * @return bean property names potentially using JSON Pointer syntax
 */
default List<String> getClause(String param, String paramName)
{
    if (param == null)
        return Collections.emptyList();

    try
    {
        CommonTree selectedPropsTree = WhereCompiler.compileSelectClause(param);
        if (selectedPropsTree instanceof CommonErrorNode)
        {
            rpeLogger().debug("Error parsing the " + paramName + " clause " + selectedPropsTree);
            throw new InvalidSelectException(paramName, selectedPropsTree);
        }
        if (selectedPropsTree.getChildCount() == 0 && !selectedPropsTree.getText().isEmpty())
        {
            return Arrays.asList(selectedPropsTree.getText());
        }
        List<Tree> children = (List<Tree>) selectedPropsTree.getChildren();
        if (children != null && !children.isEmpty())
        {
            List<String> properties = new ArrayList<String>(children.size());
            for (Tree child : children)
            {
                properties.add(child.getText());
            }
            return properties;
        }
    }
    catch (RewriteCardinalityException re)
    {
        //Catch any error so it doesn't get thrown up the stack
        rpeLogger().debug("Unhandled Error parsing the " + paramName + " clause: " + re);
    }
    catch (RecognitionException e)
    {
        rpeLogger().debug("Error parsing the \"+paramName+\" clause: " + param);
    }
    catch (InvalidQueryException iqe)
    {
        throw new InvalidSelectException(paramName, iqe.getQueryParam());
    }
    //Default to throw out an invalid query
    throw new InvalidSelectException(paramName, param);
}
 
Example 18
Source File: CMISQueryParser.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public PropertyArgument buildColumnReference(String argumentName, CommonTree columnReferenceNode,
        QueryModelFactory factory, Map<String, Selector> selectors, Map<String, Column> columnMap)
{
    String cmisPropertyName = columnReferenceNode.getChild(0).getText();
    String qualifier = "";
    if (columnReferenceNode.getChildCount() > 1)
    {
        qualifier = columnReferenceNode.getChild(1).getText();
    }

    if ((qualifier == "") && (columnMap != null))
    {
        Column column = columnMap.get(cmisPropertyName);
        if (column != null)
        {
            // check for function type
            if (column.getFunction().getName().equals(PropertyAccessor.NAME))
            {
                PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(
                        PropertyAccessor.ARG_PROPERTY);
                cmisPropertyName = arg.getPropertyName();
                qualifier = arg.getSelector();
            } else
            {
                // TODO: should be able to return non property arguments
                // The implementation should throw out what it can not
                // support at build time.
                throw new CmisInvalidArgumentException(
                        "Complex column reference unsupported (only direct column references are currently supported) "
                                + cmisPropertyName);
            }
        }
    }

    PropertyDefinitionWrapper propDef = cmisDictionaryService.findPropertyByQueryName(cmisPropertyName);
    if (propDef == null)
    {
        throw new CmisInvalidArgumentException("Unknown column/property " + cmisPropertyName);
    }

    if (selectors != null)
    {
        Selector selector = selectors.get(qualifier);
        if (selector == null)
        {
            if ((qualifier.equals("")) && (selectors.size() == 1))
            {
                selector = selectors.get(selectors.keySet().iterator().next());
            } else
            {
                throw new CmisInvalidArgumentException("No selector for " + qualifier);
            }
        }

        TypeDefinitionWrapper typeDef = cmisDictionaryService.findTypeForClass(selector.getType(), validScopes);
        if (typeDef == null)
        {
            throw new CmisInvalidArgumentException("Type unsupported in CMIS queries: " + selector.getAlias());
        }

        // Check column/property applies to selector/type

        if (typeDef.getPropertyById(propDef.getPropertyId()) == null)
        {
            throw new CmisInvalidArgumentException("Invalid column for "
                    + typeDef.getTypeDefinition(false).getQueryName() + "." + cmisPropertyName);
        }
    }

    if (options.getQueryMode() == CMISQueryMode.CMS_STRICT)
    {
        if (!propDef.getPropertyDefinition().isQueryable())
        {
            throw new CmisInvalidArgumentException("Column is not queryable " + qualifier + "." + cmisPropertyName);
        }
    }
    return factory.createPropertyArgument(argumentName, propDef.getPropertyDefinition().isQueryable(), propDef
            .getPropertyDefinition().isOrderable(), qualifier, propDef.getPropertyId());
}
 
Example 19
Source File: FTSQueryParser.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
static public PropertyArgument buildFieldReference(String argumentName, CommonTree fieldReferenceNode, QueryModelFactory factory,
        FunctionEvaluationContext functionEvaluationContext, Selector selector, Map<String, Column> columnMap)
{
    if (fieldReferenceNode.getType() != FTSParser.FIELD_REF)
    {
        throw new FTSQueryException("Not column ref  ..." + fieldReferenceNode.getText());
    }
    String fieldName = getText(fieldReferenceNode.getChild(0));
    if (columnMap != null)
    {
        for (Column column : columnMap.values())
        {
            if (column.getAlias().equals(fieldName))
            {
                // TODO: Check selector matches ...
                PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY);
                fieldName = arg.getPropertyName();
                break;
            }
        }
    }

    // prepend prefixes and name spaces

    if (fieldReferenceNode.getChildCount() > 1)
    {
        CommonTree child = (CommonTree) fieldReferenceNode.getChild(1);
        if (child.getType() == FTSParser.PREFIX)
        {
            fieldName = getText(child.getChild(0)) + ":" + fieldName;
        }
        else if (child.getType() == FTSParser.NAME_SPACE)
        {
            fieldName = getText(child.getChild(0)) + fieldName;
        }
    }

    String alias = "";
    if (selector != null)
    {
        functionEvaluationContext.checkFieldApplies(selector, fieldName);
        alias = selector.getAlias();
    }

    return factory.createPropertyArgument(argumentName, functionEvaluationContext.isQueryable(fieldName), functionEvaluationContext.isOrderable(fieldName), alias, fieldName);
}
 
Example 20
Source File: FilterSimpleExpressionCu.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Compile a simple filter expression compilation unit from a tree
 *
 * @param tree
 *            The input tree
 * @return The simple filter expression compilation unit
 */
public static @Nullable FilterSimpleExpressionCu compile(CommonTree tree) {
    if (tree.getToken() == null) {
        return null;
    }

    int childCount = tree.getChildCount();
    switch (tree.getToken().getType()) {
    case FilterParserParser.CONSTANT:
    case FilterParserParser.PAR_CONSTANT:
        StringBuilder paragraph = new StringBuilder();
        extractParagraph(tree, paragraph, 0, childCount);
        return new FilterSimpleExpressionCu(IFilterStrings.WILDCARD, IFilterStrings.MATCHES, paragraph.toString().trim());
    case FilterParserParser.OPERATION:
        String left = Objects.requireNonNull(tree.getChild(0).getText());
        String op = Objects.requireNonNull(tree.getChild(1).getText());
        String right = tree.getChild(2).getText();
        return new FilterSimpleExpressionCu(left, op, right);
    case FilterParserParser.OPERATION1:
        String left1 = Objects.requireNonNull(tree.getChild(0).getText());
        String op1 = Objects.requireNonNull(tree.getChild(1).getText());
        String right1 = null;
        return new FilterSimpleExpressionCu(left1, op1, right1);
    case FilterParserParser.OPERATION2:
    case FilterParserParser.OPERATION4:
    case FilterParserParser.OPERATION5:
        StringBuilder builder = new StringBuilder();
        int index = extractParagraph(tree, builder, 0, childCount);
        String left2 = builder.toString().trim();
        String op2 = Objects.requireNonNull(tree.getChild(index++).getText());
        builder = new StringBuilder();
        extractParagraph(tree, builder, index, childCount);
        String right2 = builder.toString().trim();
        return new FilterSimpleExpressionCu(left2, op2, right2);
    case FilterParserParser.OPERATION3:
        StringBuilder builder1 = new StringBuilder();
        int index1 = extractParagraph(tree, builder1, 0, childCount);
        String left3 = builder1.toString().trim();
        String op3 = Objects.requireNonNull(tree.getChild(index1).getText());
        String right3 = null;
        return new FilterSimpleExpressionCu(left3, op3, right3);
    case FilterParserParser.ROOT2:
        if (childCount == 0 || (childCount == 2 && tree.getChild(1).getType() != FilterParserParser.CONSTANT)) {
            return null;
        }

        boolean negate = tree.getChild(0).getText().equals(IFilterStrings.NOT);
        CommonTree expression = Objects.requireNonNull((CommonTree) tree.getChild(childCount - 1));
        FilterSimpleExpressionCu compiled = negate ? FilterSimpleExpressionNotCu.compile(expression) : FilterSimpleExpressionCu.compile(expression);
        return compiled;
    default:
        break;
    }
    return null;
}