/*
 * Created on 2004-12-21
 *
 * Part of the Symbian development plug-in for Eclipse
 * Copyright (C) Mikołaj Zalewski, 2004
 */
package pl.zalewski.mikolaj.symbdev.core.internal.mmpparser;

import java.util.Iterator;

import org.eclipse.core.resources.IMarker;

/**
 * Reads the numer represented by this token of marks it as error.
 * The number can be in decimal or in hex, if begins with '0x' 
 * 
 * @author mikolaj
 */
public class NumberTokenParser extends AbstractTokenParser {

    /**
     * @param content
     */
    public NumberTokenParser(Iterator it) {
        super(it);
    }

    protected void parse(String token) {
        try {
            if (token.startsWith("0x") || token.startsWith("0X"))
                fValue=Integer.decode(token).intValue();
            	else fValue=Integer.parseInt(token, 10);
            
        }
        catch (NumberFormatException e)
        {
            setError(IMarker.SEVERITY_ERROR, "Not a legal integer value: "+e.getLocalizedMessage());
        }
    }

    /**
     * The integer value read by this token
     */
    public int fValue;
}
