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

The following examples show how to use org.antlr.runtime.tree.CommonTree#getChild() . 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: 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 2
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 3
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 4
Source File: EncodingParser.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Gets the value of an "encoding" integer attribute.
 *
 * @return The "encoding" value.
 * @throws ParseException
 *             for unknown or malformed encoding
 */
@Override
public Encoding parse(CommonTree tree, ICommonTreeParserParameter param) throws ParseException {
    CommonTree firstChild = (CommonTree) tree.getChild(0);

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

        if (strval.equals(MetadataStrings.UTF8)) {
            return Encoding.UTF8;
        } else if (strval.equals(MetadataStrings.ASCII)) {
            return Encoding.ASCII;
        } else if (strval.equals(MetadataStrings.NONE)) {
            return Encoding.NONE;
        } else {
            throw new ParseException(INVALID_VALUE_FOR_ENCODING);
        }
    }
    throw new ParseException(INVALID_VALUE_FOR_ENCODING);

}
 
Example 5
Source File: EnumContainerParser.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Parses an enum container type node and returns the corresponding integer
 * type.
 *
 * @param enumContainerType
 *            An ENUM_CONTAINER_TYPE node.
 *
 * @return An integer declaration corresponding to the container type.
 * @throws ParseException
 *             If the type does not parse correctly or if it is not an
 *             integer type.
 */
@Override
public IntegerDeclaration parse(CommonTree enumContainerType, ICommonTreeParserParameter param) throws ParseException {
    if (!(param instanceof Param)) {
        throw new IllegalArgumentException("Param must be a " + Param.class.getCanonicalName()); //$NON-NLS-1$
    }
    Param parameter = (Param) param;
    DeclarationScope scope = parameter.fCurrentScope;

    /* Get the child, which should be a type specifier list */
    CommonTree typeSpecifierList = (CommonTree) enumContainerType.getChild(0);

    CTFTrace trace = ((Param) param).fTrace;
    /* Parse it and get the corresponding declaration */
    IDeclaration decl = TypeSpecifierListParser.INSTANCE.parse(typeSpecifierList, new TypeSpecifierListParser.Param(trace, null, null, scope));

    /* If is is an integer, return it, else throw an error */
    if (decl instanceof IntegerDeclaration) {
        return (IntegerDeclaration) decl;
    }
    throw new ParseException("enum container type must be an integer"); //$NON-NLS-1$

}
 
Example 6
Source File: CMISQueryParser.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @param orNode CommonTree
 * @param factory QueryModelFactory
 * @param functionEvaluationContext FunctionEvaluationContext
 * @param selectors Map<String, Selector>
 * @param columnMap HashMap<String, Column>
 * @return Constraint
 */
private Constraint buildDisjunction(CommonTree orNode, QueryModelFactory factory,
        FunctionEvaluationContext functionEvaluationContext, Map<String, Selector> selectors,
        HashMap<String, Column> columnMap)
{
    List<Constraint> constraints = new ArrayList<Constraint>(orNode.getChildCount());
    for (int i = 0; i < orNode.getChildCount(); i++)
    {
        CommonTree andNode = (CommonTree) orNode.getChild(i);
        Constraint constraint = buildConjunction(andNode, factory, functionEvaluationContext, selectors, columnMap);
        constraints.add(constraint);
    }
    if (constraints.size() == 1)
    {
        return constraints.get(0);
    } else
    {
        return factory.createDisjunction(constraints);
    }
}
 
Example 7
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 8
Source File: TypeSpecifierListNameParser.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void parseEnum(CommonTree typeSpecifier, StringBuilder sb) throws ParseException {
    CommonTree enumName = (CommonTree) typeSpecifier.getFirstChildWithType(CTFParser.ENUM_NAME);
    if (enumName == null) {
        throw new ParseException("nameless enum found in createTypeSpecifierString"); //$NON-NLS-1$
    }

    CommonTree enumNameIdentifier = (CommonTree) enumName.getChild(0);

    parseSimple(enumNameIdentifier, sb);
}
 
Example 9
Source File: TypeSpecifierListNameParser.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void parseVariant(CommonTree typeSpecifier, StringBuilder sb) throws ParseException {
    CommonTree variantName = (CommonTree) typeSpecifier.getFirstChildWithType(CTFParser.VARIANT_NAME);
    if (variantName == null) {
        throw new ParseException("nameless variant found in createTypeSpecifierString"); //$NON-NLS-1$
    }

    CommonTree variantNameIdentifier = (CommonTree) variantName.getChild(0);

    parseSimple(variantNameIdentifier, sb);
}
 
Example 10
Source File: FilterSimpleExpressionCu.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static int extractParagraph(CommonTree tree, StringBuilder builder, int index, int count) {
    String separator = " "; //$NON-NLS-1$
    int i;
    boolean stop = false;
    for (i = index; i < count && !stop; i++) {
        Tree child = tree.getChild(i);
        if (child.getType() != FilterParserParser.TEXT) {
            stop = true;
            continue;
        }
        builder.append(child.getText());
        builder.append(separator);
    }
    return --i;
}
 
Example 11
Source File: StreamDeclarationParser.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static DeclarationScope lookupStructName(CommonTree typeSpecifier, DeclarationScope scope) {
    /*
     * This needs a struct.struct_name.name to work, luckily, that is 99.99%
     * of traces we receive.
     */
    final Tree potentialStruct = typeSpecifier.getChild(0);
    DeclarationScope eventHeaderScope = null;
    if (potentialStruct.getType() == (CTFParser.STRUCT)) {
        final Tree potentialStructName = potentialStruct.getChild(0);
        if (potentialStructName.getType() == (CTFParser.STRUCT_NAME)) {
            final String name = potentialStructName.getChild(0).getText();
            eventHeaderScope = scope.lookupChildRecursive(name);
            if (eventHeaderScope == null) {
                eventHeaderScope = lookupScopeRecursiveStruct(name, scope);
            }
        }
    }
    /*
     * If that fails, maybe the struct is anonymous
     */
    if (eventHeaderScope == null) {
        eventHeaderScope = scope.lookupChildRecursive(MetadataStrings.STRUCT);
    }

    /*
     * This can still be null
     */
    return eventHeaderScope;
}
 
Example 12
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 13
Source File: EventNameParser.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String parse(CommonTree tree, ICommonTreeParserParameter param) throws ParseException {
    CommonTree firstChild = (CommonTree) tree.getChild(0);

    if (isAnyUnaryString(firstChild)) {
        return concatenateUnaryStrings(tree.getChildren());
    }
    throw new ParseException("invalid value for event name"); //$NON-NLS-1$
}
 
Example 14
Source File: TypeSpecifierListNameParser.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void parseStruct(CommonTree typeSpecifier, StringBuilder sb) throws ParseException {
    CommonTree structName = (CommonTree) typeSpecifier.getFirstChildWithType(CTFParser.STRUCT_NAME);
    if (structName == null) {
        throw new ParseException("nameless struct found in createTypeSpecifierString"); //$NON-NLS-1$
    }

    CommonTree structNameIdentifier = (CommonTree) structName.getChild(0);

    parseSimple(structNameIdentifier, sb);
}
 
Example 15
Source File: FTSQueryParser.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
static private void setBoost(Constraint constraint, CommonTree subNode)
{
    for (int i = 0, l = subNode.getChildCount(); i < l; i++)
    {
        CommonTree child = (CommonTree) subNode.getChild(i);
        if (child.getType() == FTSParser.BOOST)
        {
            String boostString = child.getChild(0).getText();
            float boost = Float.parseFloat(boostString);
            constraint.setBoost(boost);
            return;
        }
    }
}
 
Example 16
Source File: IntegerDeclarationParser.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Parses an integer declaration node.
 *
 * @param parameter
 *            parent trace, for byte orders
 *
 * @return The corresponding integer declaration.
 */
@Override
public IntegerDeclaration parse(CommonTree integer, ICommonTreeParserParameter parameter) throws ParseException {
    if (!(parameter instanceof Param)) {
        throw new IllegalArgumentException("Param must be a " + Param.class.getCanonicalName()); //$NON-NLS-1$
    }
    CTFTrace trace = ((Param) parameter).fTrace;
    List<CommonTree> children = integer.getChildren();

    /*
     * If the integer has no attributes, then it is missing the size
     * attribute which is required
     */
    if (children == null) {
        throw new ParseException("integer: missing size attribute"); //$NON-NLS-1$
    }

    /* The return value */
    IntegerDeclaration integerDeclaration = null;
    boolean signed = false;
    ByteOrder byteOrder = trace.getByteOrder();
    long size = 0;
    long alignment = 0;
    int base = DEFAULT_INT_BASE;
    @NonNull
    String clock = EMPTY_STRING;

    Encoding encoding = Encoding.NONE;

    /* Iterate on all integer children */
    for (CommonTree child : children) {
        switch (child.getType()) {
        case CTFParser.CTF_EXPRESSION_VAL:
            /*
             * An assignment expression must have 2 children, left and right
             */

            CommonTree leftNode = (CommonTree) child.getChild(0);
            CommonTree rightNode = (CommonTree) child.getChild(1);

            List<CommonTree> leftStrings = leftNode.getChildren();

            if (!isAnyUnaryString(leftStrings.get(0))) {
                throw new ParseException("Left side of ctf expression must be a string"); //$NON-NLS-1$
            }
            String left = concatenateUnaryStrings(leftStrings);

            switch (left) {
            case SIGNED:
                signed = SignedParser.INSTANCE.parse(rightNode, null);
                break;
            case MetadataStrings.BYTE_ORDER:
                byteOrder = ByteOrderParser.INSTANCE.parse(rightNode, new ByteOrderParser.Param(trace));
                break;
            case SIZE:
                size = SizeParser.INSTANCE.parse(rightNode, null);
                break;
            case MetadataStrings.ALIGN:
                alignment = AlignmentParser.INSTANCE.parse(rightNode, null);
                break;
            case BASE:
                base = BaseParser.INSTANCE.parse(rightNode, null);
                break;
            case ENCODING:
                encoding = EncodingParser.INSTANCE.parse(rightNode, null);
                break;
            case MAP:
                clock = ClockMapParser.INSTANCE.parse(rightNode, null);
                break;
            default:
                Activator.log(IStatus.WARNING, Messages.IOStructGen_UnknownIntegerAttributeWarning + " " + left); //$NON-NLS-1$
                break;
            }

            break;
        default:
            throw childTypeError(child);
        }
    }

    if (size <= 0) {
        throw new ParseException("Invalid size attribute in Integer: " + size); //$NON-NLS-1$
    }

    if (alignment == 0) {
        alignment = 1;
    }

    integerDeclaration = IntegerDeclaration.createDeclaration((int) size, signed, base,
            byteOrder, encoding, clock, alignment);

    return integerDeclaration;
}
 
Example 17
Source File: BaseParser.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Integer parse(CommonTree tree, ICommonTreeParserParameter param) throws ParseException {

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

    if (isUnaryInteger(firstChild)) {
        if (tree.getChildCount() > 1) {
            throw new ParseException("invalid base value"); //$NON-NLS-1$
        }

        long intval = UnaryIntegerParser.INSTANCE.parse(firstChild, null);
        if ((intval == INTEGER_BASE_2) || (intval == INTEGER_BASE_8) || (intval == INTEGER_BASE_10)
                || (intval == INTEGER_BASE_16)) {
            return (int) intval;
        }
        throw new ParseException(INVALID_VALUE_FOR_BASE);
    } else if (isUnaryString(firstChild)) {
        switch (concatenateUnaryStrings(tree.getChildren())) {
        case MetadataStrings.DECIMAL:
        case MetadataStrings.DEC:
        case MetadataStrings.DEC_CTE:
        case MetadataStrings.INT_MOD:
        case MetadataStrings.UNSIGNED_CTE:
            return INTEGER_BASE_10;
        case MetadataStrings.HEXADECIMAL:
        case MetadataStrings.HEX:
        case MetadataStrings.X:
        case MetadataStrings.X2:
        case MetadataStrings.POINTER:
            return INTEGER_BASE_16;
        case MetadataStrings.OCT:
        case MetadataStrings.OCTAL:
        case MetadataStrings.OCTAL_CTE:
            return INTEGER_BASE_8;
        case MetadataStrings.BIN:
        case MetadataStrings.BINARY:
            return INTEGER_BASE_2;
        default:
            throw new ParseException(INVALID_VALUE_FOR_BASE);
        }
    } else {
        throw new ParseException(INVALID_VALUE_FOR_BASE);
    }
}
 
Example 18
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 19
Source File: StringDeclarationParser.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Parse a string declaration node and return a {@link StringDeclaration}
 *
 * @param string
 *            the string declaration AST node
 * @param unused
 *            unused
 * @return a {@link StringDeclaration} describing the string layout
 * @throws ParseException
 *             the AST is malformed
 */
@Override
public StringDeclaration parse(CommonTree string, ICommonTreeParserParameter unused) throws ParseException {
    List<CommonTree> children = string.getChildren();
    StringDeclaration stringDeclaration = null;

    if (children == null) {
        stringDeclaration = StringDeclaration.getStringDeclaration(Encoding.UTF8);
    } else {
        Encoding encoding = Encoding.UTF8;
        for (CommonTree child : children) {
            switch (child.getType()) {
            case CTFParser.CTF_EXPRESSION_VAL:
                /*
                 * An assignment expression must have 2 children, left and
                 * right
                 */

                CommonTree leftNode = (CommonTree) child.getChild(0);
                CommonTree rightNode = (CommonTree) child.getChild(1);

                List<CommonTree> leftStrings = leftNode.getChildren();

                if (!isAnyUnaryString(leftStrings.get(0))) {
                    throw new ParseException("Left side of ctf expression must be a string"); //$NON-NLS-1$
                }
                String left = concatenateUnaryStrings(leftStrings);

                if (left.equals(ENCODING)) {
                    encoding = EncodingParser.INSTANCE.parse(rightNode, null);
                } else {
                    throw new ParseException("String: unknown attribute " //$NON-NLS-1$
                            + left);
                }

                break;
            default:
                throw childTypeError(child);
            }
        }

        stringDeclaration = StringDeclaration.getStringDeclaration(encoding);
    }

    return stringDeclaration;
}
 
Example 20
Source File: FloatDeclarationParser.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Parses a float node and returns a floating point declaration of the
 * type @link {@link FloatDeclaration}.
 *
 * @param floatingPoint
 *            AST node of type FLOAT
 * @param param
 *            parameter containing the trace
 * @return the float declaration
 * @throws ParseException
 *             if a float AST is malformed
 */
@Override
public FloatDeclaration parse(CommonTree floatingPoint, ICommonTreeParserParameter param) throws ParseException {
    if (!(param instanceof Param)) {
        throw new IllegalArgumentException("Param must be a " + Param.class.getCanonicalName()); //$NON-NLS-1$
    }
    CTFTrace trace = ((Param) param).fTrace;
    List<CommonTree> children = floatingPoint.getChildren();

    /*
     * If the integer has no attributes, then it is missing the size
     * attribute which is required
     */
    if (children == null) {
        throw new ParseException(FLOAT_MISSING_SIZE_ATTRIBUTE);
    }

    /* The return value */
    ByteOrder byteOrder = trace.getByteOrder();
    long alignment = 0;

    int exponent = DEFAULT_FLOAT_EXPONENT;
    int mantissa = DEFAULT_FLOAT_MANTISSA;

    /* Iterate on all integer children */
    for (CommonTree child : children) {
        switch (child.getType()) {
        case CTFParser.CTF_EXPRESSION_VAL:
            /*
             * An assignment expression must have 2 children, left and right
             */

            CommonTree leftNode = (CommonTree) child.getChild(0);
            CommonTree rightNode = (CommonTree) child.getChild(1);

            List<CommonTree> leftStrings = leftNode.getChildren();

            if (!isAnyUnaryString(leftStrings.get(0))) {
                throw new ParseException(IDENTIFIER_MUST_BE_A_STRING);
            }
            String left = concatenateUnaryStrings(leftStrings);

            if (left.equals(MetadataStrings.EXP_DIG)) {
                exponent = UnaryIntegerParser.INSTANCE.parse((CommonTree) rightNode.getChild(0), null).intValue();
            } else if (left.equals(MetadataStrings.BYTE_ORDER)) {
                byteOrder = ByteOrderParser.INSTANCE.parse(rightNode, new ByteOrderParser.Param(trace));
            } else if (left.equals(MetadataStrings.MANT_DIG)) {
                mantissa = UnaryIntegerParser.INSTANCE.parse((CommonTree) rightNode.getChild(0), null).intValue();
            } else if (left.equals(MetadataStrings.ALIGN)) {
                alignment = AlignmentParser.INSTANCE.parse(rightNode, null);
            } else {
                throw new ParseException(FLOAT_UNKNOWN_ATTRIBUTE + left);
            }

            break;
        default:
            throw childTypeError(child);
        }
    }
    int size = mantissa + exponent;
    if (size == 0) {
        throw new ParseException(FLOAT_MISSING_SIZE_ATTRIBUTE);
    }

    if (alignment == 0) {
        alignment = 1;
    }

    return new FloatDeclaration(exponent, mantissa, byteOrder, alignment);

}