incubator-imperius-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: svn commit: r611261 [2/43] - in /incubator/imperius/trunk: ./ imperius-javaspl/ imperius-javaspl/src/main/java/org/apache/imperius/javaspl/ imperius-splcore/ imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/ imperius-splcore/src/...
Date Sat, 12 Jan 2008 20:58:54 GMT
Hi Kevan,

It's too late for this exercise, but I discovered by accident that  
"all you need to do" to fix line endings is to set the svn:eol-style  
property, and svn automatically converts the file to consistent line  
endings.

Craig

On Jan 11, 2008, at 10:57 AM, kevan@apache.org wrote:

> Modified: incubator/imperius/trunk/imperius-javaspl/src/main/java/ 
> org/apache/imperius/javaspl/JavaSPLTypeConstants.java
> URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius- 
> javaspl/src/main/java/org/apache/imperius/javaspl/ 
> JavaSPLTypeConstants.java?rev=611261&r1=611260&r2=611261&view=diff
> ====================================================================== 
> ========
> --- incubator/imperius/trunk/imperius-javaspl/src/main/java/org/ 
> apache/imperius/javaspl/JavaSPLTypeConstants.java (original)
> +++ incubator/imperius/trunk/imperius-javaspl/src/main/java/org/ 
> apache/imperius/javaspl/JavaSPLTypeConstants.java Fri Jan 11  
> 10:56:30 2008
> @@ -1,323 +1,323 @@
> -/*
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - *      http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing,  
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> - * See the License for the specific language governing permissions  
> and
> - * limitations under the License.
> - */
> -//
> -
> -/**
> - * @author Neeraj Joshi <jneeraj@us.ibm.com>
> - *
> - *  This class provides methods to map java types to SPL types and  
> vice
> - *  versa
> - */
> -package org.apache.imperius.javaspl;
> -
> -
> -import java.util.logging.Logger;
> -
> -import org.apache.imperius.spl.external.TypeConstants;
> -import org.apache.imperius.spl.parser.exceptions.*;
> -import org.apache.imperius.util.SPLLogger;
> -
> -
> -
> -public class JavaSPLTypeConstants
> -{
> -
> -    private static Logger logger = SPLLogger.getSPLLogger 
> ().getLogger();
> -    private static final String sourceClass="JavaSPLTypeConstants";
> -
> -    public static boolean getIsArray(String type)
> -    {
> -    	if(type.startsWith("["))
> -    	{
> -    		return true;
> -    	}
> -    	return false;
> -    	
> -    }
> -    public static Class convertInternalTypeToJavaType(int type,  
> boolean isArray,
> -    		String referenceName) throws ClassNotFoundException
> -    {
> -    	Class javaType = null;
> -    	if(type == TypeConstants.byteType)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[B");
> -    		}
> -    		else
> -    		{
> -    			
> -    			javaType = Byte.TYPE;
> -    		}
> -    	}
> -    	else if(type == TypeConstants.shortType)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[S");
> -    		}
> -    		else
> -    		{
> -    			javaType = Short.TYPE;
> -    		}
> -    	}
> -    	else if(type == TypeConstants.intType)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[I");
> -    		}
> -    		else
> -    		{
> -    			javaType = Integer.TYPE;
> -    		}
> -    	}
> -    	else if(type == TypeConstants.longType)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[J");
> -    		}
> -    		else
> -    		{
> -    			javaType = Long.TYPE;
> -    		}
> -    	}
> -    	else if(type == TypeConstants.floatType)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[F");
> -    		}
> -    		else
> -    		{
> -    			javaType = Float.TYPE;
> -    		}
> -    	}
> -    	else if(type == TypeConstants.doubleType)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[D");
> -    		}
> -    		else
> -    		{
> -    			javaType = Double.TYPE;
> -    		}
> -    	}
> -    	else if(type == TypeConstants.booleanType)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[Z");
> -    		}
> -    		else
> -    		{
> -    			javaType = Boolean.TYPE;
> -    		}
> -    	}
> -    	else if(type == TypeConstants.charType)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[C");
> -    		}
> -    		else
> -    		{
> -    			javaType = Character.TYPE;
> -    		}
> -    	}
> -    	else if(type == TypeConstants.stringType)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[Ljava.lang.String;");
> -    		}
> -    		else
> -    		{
> -    			javaType = Class.forName("java.lang.String");
> -    		}
> -    	}
> -    	else if(type == TypeConstants.dateTime)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[Ljava.util.Calendar;");
> -    		}
> -    		else
> -    		{
> -    			javaType = Class.forName("Ljava.util.Calendar");
> -    		}
> -    	}
> -    	else if(type == TypeConstants.referenceType)
> -    	{
> -    		if(isArray)
> -    		{
> -    			javaType = Class.forName("[L" + referenceName + ";");
> -    		}
> -    		else
> -    		{
> -    			javaType = Class.forName(referenceName);
> -    		}
> -    	}
> -    	return javaType;
> -    	
> -    		
> -    	
> -    }
> -
> -    public static int convertJavaTypeToInternalType(String type)
> -    {
> -
> -
> -        int retTp = TypeConstants.INVALID;
> -
> -        if (type.equals("byte") || type.equals("[B"))
> -        {
> -            retTp = TypeConstants.byteType;
> -        }
> -        else if (type.equals("short") || type.equals("[S"))
> -        {
> -            retTp = TypeConstants.shortType;
> -        }
> -        else if (type.equals("int") || type.equals("[I"))
> -        {
> -            retTp = TypeConstants.intType;
> -        }
> -        else if (type.equals("long") || type.equals("[J"))
> -        {
> -            retTp = TypeConstants.longType;
> -        }
> -        else if (type.equals("float") || type.equals("[F"))
> -        {
> -            retTp = TypeConstants.floatType;
> -        }
> -        else if (type.equals("double") || type.equals("[D"))
> -        {
> -            retTp = TypeConstants.doubleType;
> -        }
> -        else if (type.equals("boolean") || type.equals("[Z"))
> -        {
> -            retTp = TypeConstants.booleanType;
> -        }
> -        else if (type.equals("char") || type.equals("[C"))
> -        {
> -            retTp = TypeConstants.charType;
> -        }
> -        else if (type.equals("java.lang.String")
> -        		|| type.equals("[Ljava.lang.String;")
> -        		|| type.equals("class java.lang.String"))
> -        {
> -            retTp = TypeConstants.stringType;
> -        }
> -        else if (type.equals("java.util.Calendar") || type.equals 
> ("[Ljava.util.Calendar;"))
> -       	{
> -        	retTp = TypeConstants.dateTime;
> -       	}
> -        else
> -        {
> -            retTp = TypeConstants.referenceType;
> -
> -        }
> -        return retTp;
> -
> -    }
> -
> -
> -
> -    public static int getTypeOfObject(Object ob) throws  
> TypeMismatchException
> -    {
> -        logger.entering(sourceClass,Thread.currentThread().getName 
> ()+" "+ "getTypeOfObject");
> -
> -        int currentLocaltype = -1;
> -        if (ob instanceof java.lang.Boolean)
> -        {	
> -            currentLocaltype = TypeConstants.booleanType;
> -        }
> -        else if (ob instanceof java.lang.String)
> -        {	
> -            currentLocaltype = TypeConstants.stringType;
> -        }
> -        else if (ob instanceof java.util.Calendar || ob instanceof  
> java.util.Date)
> -        {	
> -            currentLocaltype = TypeConstants.dateTime;
> -        }
> -        else if (ob instanceof java.lang.Byte)
> -        {	
> -            currentLocaltype = TypeConstants.byteType;
> -        }
> -        else if (ob instanceof java.lang.Character)
> -        {	
> -            currentLocaltype = TypeConstants.charType;
> -        }
> -        else if (ob instanceof java.lang.Short)
> -        {	
> -            currentLocaltype = TypeConstants.shortType;
> -        }
> -        else if (ob instanceof java.lang.Integer)
> -        {	
> -            currentLocaltype = TypeConstants.intType;
> -        }
> -        else if (ob instanceof java.lang.Long)
> -        {	
> -            currentLocaltype = TypeConstants.longType;
> -        }
> -        else if (ob instanceof java.lang.Float)
> -        {	
> -            currentLocaltype = TypeConstants.floatType;
> -        }
> -        else if (ob instanceof java.lang.Double)
> -        {	
> -            currentLocaltype = TypeConstants.doubleType;
> -        }
> -        else
> -        {	
> -            currentLocaltype = TypeConstants.referenceType;
> -        }
> -
> -
> -        return currentLocaltype;
> -    }
> -	public static String getReferenceTypeName(String javaType)
> -	{
> -		
> -		//extract class name and return
> -		String referenceType = null;
> -		if(convertJavaTypeToInternalType(javaType) ==  
> TypeConstants.referenceType)
> -		{	
> -			if(javaType.startsWith("["))
> -			{
> -				referenceType = javaType.substring(1);
> -			
> -			}
> -			else
> -			{
> -				if(javaType.startsWith("class ")) // of type class com.ibm.xxx
> -				{
> -					int ind = javaType.indexOf(' ');
> -					referenceType = javaType.substring(ind + 1);
> -				}
> -				else
> -				{
> -					referenceType = javaType;
> -				}	
> -			}
> -		}
> -		else
> -		{
> -			System.out.println("Only reference types have referenceType  
> names" + javaType);
> -		}
> -		return referenceType;
> -	}
> -}
> +/*
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> + */
> +//
> +
> +/**
> + * @author Neeraj Joshi <jneeraj@us.ibm.com>
> + *
> + *  This class provides methods to map java types to SPL types and  
> vice
> + *  versa
> + */
> +package org.apache.imperius.javaspl;
> +
> +
> +import java.util.logging.Logger;
> +
> +import org.apache.imperius.spl.external.TypeConstants;
> +import org.apache.imperius.spl.parser.exceptions.*;
> +import org.apache.imperius.util.SPLLogger;
> +
> +
> +
> +public class JavaSPLTypeConstants
> +{
> +
> +    private static Logger logger = SPLLogger.getSPLLogger 
> ().getLogger();
> +    private static final String sourceClass="JavaSPLTypeConstants";
> +
> +    public static boolean getIsArray(String type)
> +    {
> +    	if(type.startsWith("["))
> +    	{
> +    		return true;
> +    	}
> +    	return false;
> +    	
> +    }
> +    public static Class convertInternalTypeToJavaType(int type,  
> boolean isArray,
> +    		String referenceName) throws ClassNotFoundException
> +    {
> +    	Class javaType = null;
> +    	if(type == TypeConstants.byteType)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[B");
> +    		}
> +    		else
> +    		{
> +    			
> +    			javaType = Byte.TYPE;
> +    		}
> +    	}
> +    	else if(type == TypeConstants.shortType)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[S");
> +    		}
> +    		else
> +    		{
> +    			javaType = Short.TYPE;
> +    		}
> +    	}
> +    	else if(type == TypeConstants.intType)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[I");
> +    		}
> +    		else
> +    		{
> +    			javaType = Integer.TYPE;
> +    		}
> +    	}
> +    	else if(type == TypeConstants.longType)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[J");
> +    		}
> +    		else
> +    		{
> +    			javaType = Long.TYPE;
> +    		}
> +    	}
> +    	else if(type == TypeConstants.floatType)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[F");
> +    		}
> +    		else
> +    		{
> +    			javaType = Float.TYPE;
> +    		}
> +    	}
> +    	else if(type == TypeConstants.doubleType)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[D");
> +    		}
> +    		else
> +    		{
> +    			javaType = Double.TYPE;
> +    		}
> +    	}
> +    	else if(type == TypeConstants.booleanType)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[Z");
> +    		}
> +    		else
> +    		{
> +    			javaType = Boolean.TYPE;
> +    		}
> +    	}
> +    	else if(type == TypeConstants.charType)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[C");
> +    		}
> +    		else
> +    		{
> +    			javaType = Character.TYPE;
> +    		}
> +    	}
> +    	else if(type == TypeConstants.stringType)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[Ljava.lang.String;");
> +    		}
> +    		else
> +    		{
> +    			javaType = Class.forName("java.lang.String");
> +    		}
> +    	}
> +    	else if(type == TypeConstants.dateTime)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[Ljava.util.Calendar;");
> +    		}
> +    		else
> +    		{
> +    			javaType = Class.forName("Ljava.util.Calendar");
> +    		}
> +    	}
> +    	else if(type == TypeConstants.referenceType)
> +    	{
> +    		if(isArray)
> +    		{
> +    			javaType = Class.forName("[L" + referenceName + ";");
> +    		}
> +    		else
> +    		{
> +    			javaType = Class.forName(referenceName);
> +    		}
> +    	}
> +    	return javaType;
> +    	
> +    		
> +    	
> +    }
> +
> +    public static int convertJavaTypeToInternalType(String type)
> +    {
> +
> +
> +        int retTp = TypeConstants.INVALID;
> +
> +        if (type.equals("byte") || type.equals("[B"))
> +        {
> +            retTp = TypeConstants.byteType;
> +        }
> +        else if (type.equals("short") || type.equals("[S"))
> +        {
> +            retTp = TypeConstants.shortType;
> +        }
> +        else if (type.equals("int") || type.equals("[I"))
> +        {
> +            retTp = TypeConstants.intType;
> +        }
> +        else if (type.equals("long") || type.equals("[J"))
> +        {
> +            retTp = TypeConstants.longType;
> +        }
> +        else if (type.equals("float") || type.equals("[F"))
> +        {
> +            retTp = TypeConstants.floatType;
> +        }
> +        else if (type.equals("double") || type.equals("[D"))
> +        {
> +            retTp = TypeConstants.doubleType;
> +        }
> +        else if (type.equals("boolean") || type.equals("[Z"))
> +        {
> +            retTp = TypeConstants.booleanType;
> +        }
> +        else if (type.equals("char") || type.equals("[C"))
> +        {
> +            retTp = TypeConstants.charType;
> +        }
> +        else if (type.equals("java.lang.String")
> +        		|| type.equals("[Ljava.lang.String;")
> +        		|| type.equals("class java.lang.String"))
> +        {
> +            retTp = TypeConstants.stringType;
> +        }
> +        else if (type.equals("java.util.Calendar") || type.equals 
> ("[Ljava.util.Calendar;"))
> +       	{
> +        	retTp = TypeConstants.dateTime;
> +       	}
> +        else
> +        {
> +            retTp = TypeConstants.referenceType;
> +
> +        }
> +        return retTp;
> +
> +    }
> +
> +
> +
> +    public static int getTypeOfObject(Object ob) throws  
> TypeMismatchException
> +    {
> +        logger.entering(sourceClass,Thread.currentThread().getName 
> ()+" "+ "getTypeOfObject");
> +
> +        int currentLocaltype = -1;
> +        if (ob instanceof java.lang.Boolean)
> +        {	
> +            currentLocaltype = TypeConstants.booleanType;
> +        }
> +        else if (ob instanceof java.lang.String)
> +        {	
> +            currentLocaltype = TypeConstants.stringType;
> +        }
> +        else if (ob instanceof java.util.Calendar || ob instanceof  
> java.util.Date)
> +        {	
> +            currentLocaltype = TypeConstants.dateTime;
> +        }
> +        else if (ob instanceof java.lang.Byte)
> +        {	
> +            currentLocaltype = TypeConstants.byteType;
> +        }
> +        else if (ob instanceof java.lang.Character)
> +        {	
> +            currentLocaltype = TypeConstants.charType;
> +        }
> +        else if (ob instanceof java.lang.Short)
> +        {	
> +            currentLocaltype = TypeConstants.shortType;
> +        }
> +        else if (ob instanceof java.lang.Integer)
> +        {	
> +            currentLocaltype = TypeConstants.intType;
> +        }
> +        else if (ob instanceof java.lang.Long)
> +        {	
> +            currentLocaltype = TypeConstants.longType;
> +        }
> +        else if (ob instanceof java.lang.Float)
> +        {	
> +            currentLocaltype = TypeConstants.floatType;
> +        }
> +        else if (ob instanceof java.lang.Double)
> +        {	
> +            currentLocaltype = TypeConstants.doubleType;
> +        }
> +        else
> +        {	
> +            currentLocaltype = TypeConstants.referenceType;
> +        }
> +
> +
> +        return currentLocaltype;
> +    }
> +	public static String getReferenceTypeName(String javaType)
> +	{
> +		
> +		//extract class name and return
> +		String referenceType = null;
> +		if(convertJavaTypeToInternalType(javaType) ==  
> TypeConstants.referenceType)
> +		{	
> +			if(javaType.startsWith("["))
> +			{
> +				referenceType = javaType.substring(1);
> +			
> +			}
> +			else
> +			{
> +				if(javaType.startsWith("class ")) // of type class com.ibm.xxx
> +				{
> +					int ind = javaType.indexOf(' ');
> +					referenceType = javaType.substring(ind + 1);
> +				}
> +				else
> +				{
> +					referenceType = javaType;
> +				}	
> +			}
> +		}
> +		else
> +		{
> +			System.out.println("Only reference types have referenceType  
> names" + javaType);
> +		}
> +		return referenceType;
> +	}
> +}
>
> Propchange: incubator/imperius/trunk/imperius-javaspl/src/main/java/ 
> org/apache/imperius/javaspl/JavaSPLTypeConstants.java
> ---------------------------------------------------------------------- 
> --------
>     svn:eol-style = native
>
> Modified: incubator/imperius/trunk/imperius-javaspl/src/main/java/ 
> org/apache/imperius/javaspl/Java_SPLPolicyRuleProvider.java
> URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius- 
> javaspl/src/main/java/org/apache/imperius/javaspl/ 
> Java_SPLPolicyRuleProvider.java? 
> rev=611261&r1=611260&r2=611261&view=diff
> ====================================================================== 
> ========
> --- incubator/imperius/trunk/imperius-javaspl/src/main/java/org/ 
> apache/imperius/javaspl/Java_SPLPolicyRuleProvider.java (original)
> +++ incubator/imperius/trunk/imperius-javaspl/src/main/java/org/ 
> apache/imperius/javaspl/Java_SPLPolicyRuleProvider.java Fri Jan 11  
> 10:56:30 2008
> @@ -1,146 +1,146 @@
> -/*
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - *      http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing,  
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> - * See the License for the specific language governing permissions  
> and
> - * limitations under the License.
> - */
> -//
> -
> -/**
> - * @author Prashant Baliga <prabalig@in.ibm.com>
> - *
> - */
> -
> -
> -package org.apache.imperius.javaspl;
> -
> -
> -import java.util.List;
> -import java.util.Map;
> -
> -import org.apache.imperius.spl.external.Actuator;
> -import org.apache.imperius.spl.external.DataCollector;
> -import org.apache.imperius.spl.manager.PolicyManager;
> -import org.apache.imperius.spl.manager.impl.PolicyManagerImpl;
> -import org.apache.imperius.spl.parser.exceptions.SPLException;
> -
> -
> -
> -
> -
> -public class Java_SPLPolicyRuleProvider
> -{
> -
> -	
> -	private PolicyManager _policyManager= null;
> -	
> -	
> -	public Java_SPLPolicyRuleProvider() throws SPLException
> -	{
> -		initialize();
> -		
> -	}
> -	
> -	public void cleanup() throws SPLException {
> -		
> -
> -		
> -	}
> -
> -	public void initialize() throws SPLException
> -	{
> -	
> -		
> -		DataCollector dc = new JavaDataCollectorImpl();
> -		Actuator ac = new JavaActuatorImpl();
> -		
> -		
> -		_policyManager= new PolicyManagerImpl(dc,ac);
> -			
> -		
> -	}
> -
> -
> -	public boolean createPolicy(String name, String policyString)  
> throws SPLException
> -	{
> -		
> -        boolean result = _policyManager.createPolicy 
> (name,policyString);
> -
> -		return result;
> -	}
> -	
> -	public boolean validatePolicyString(String policyString) throws  
> SPLException
> -	{
> -		
> -        boolean result = _policyManager.validatePolicyString 
> (policyString);
> -
> -		return result;
> -	}
> -
> -	public void deletePolicy(String name) throws SPLException
> -	{
> -		
> -		_policyManager.deletePolicy(name);
> -		
> -		return;
> -	}
> -
> -	public List enumeratePolicyNames() throws SPLException
> -	{
> -
> -        List policyNames = _policyManager.getAllPolicyNames();
> -		
> -		return policyNames;
> -	}
> -
> -	public Map enumeratePolicies() throws SPLException
> -	{
> -
> -        Map policyInstances = _policyManager.getAllPolicies();
> -		
> -		return policyInstances;
> -
> -	}
> -
> -	
> -	public String getPolicy(String policyName) throws SPLException
> -	{
> -
> -        String policy = _policyManager.getPolicy(policyName);
> -		
> -		return policy;
> -
> -	}
> -
> -	public void modifyPolicy(String name, String policyString) throws  
> SPLException {
> -
> -		
> -		_policyManager.updatePolicy(name,policyString);
> -
> -
> -	}
> -
> -	public Object executePolicy(String policyName, Map  
> instanceObjectMap) throws SPLException
> -	{
> -	
> -
> -		Object retVal = _policyManager.evaluatePolicy 
> (policyName,instanceObjectMap);
> -
> -
> -		return retVal;
> -	}
> -	
> -	public static void main(String [] args)
> -	{
> -		
> -
> -	}
> -
> -}
> +/*
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> + */
> +//
> +
> +/**
> + * @author Prashant Baliga <prabalig@in.ibm.com>
> + *
> + */
> +
> +
> +package org.apache.imperius.javaspl;
> +
> +
> +import java.util.List;
> +import java.util.Map;
> +
> +import org.apache.imperius.spl.external.Actuator;
> +import org.apache.imperius.spl.external.DataCollector;
> +import org.apache.imperius.spl.manager.PolicyManager;
> +import org.apache.imperius.spl.manager.impl.PolicyManagerImpl;
> +import org.apache.imperius.spl.parser.exceptions.SPLException;
> +
> +
> +
> +
> +
> +public class Java_SPLPolicyRuleProvider
> +{
> +
> +	
> +	private PolicyManager _policyManager= null;
> +	
> +	
> +	public Java_SPLPolicyRuleProvider() throws SPLException
> +	{
> +		initialize();
> +		
> +	}
> +	
> +	public void cleanup() throws SPLException {
> +		
> +
> +		
> +	}
> +
> +	public void initialize() throws SPLException
> +	{
> +	
> +		
> +		DataCollector dc = new JavaDataCollectorImpl();
> +		Actuator ac = new JavaActuatorImpl();
> +		
> +		
> +		_policyManager= new PolicyManagerImpl(dc,ac);
> +			
> +		
> +	}
> +
> +
> +	public boolean createPolicy(String name, String policyString)  
> throws SPLException
> +	{
> +		
> +        boolean result = _policyManager.createPolicy 
> (name,policyString);
> +
> +		return result;
> +	}
> +	
> +	public boolean validatePolicyString(String policyString) throws  
> SPLException
> +	{
> +		
> +        boolean result = _policyManager.validatePolicyString 
> (policyString);
> +
> +		return result;
> +	}
> +
> +	public void deletePolicy(String name) throws SPLException
> +	{
> +		
> +		_policyManager.deletePolicy(name);
> +		
> +		return;
> +	}
> +
> +	public List enumeratePolicyNames() throws SPLException
> +	{
> +
> +        List policyNames = _policyManager.getAllPolicyNames();
> +		
> +		return policyNames;
> +	}
> +
> +	public Map enumeratePolicies() throws SPLException
> +	{
> +
> +        Map policyInstances = _policyManager.getAllPolicies();
> +		
> +		return policyInstances;
> +
> +	}
> +
> +	
> +	public String getPolicy(String policyName) throws SPLException
> +	{
> +
> +        String policy = _policyManager.getPolicy(policyName);
> +		
> +		return policy;
> +
> +	}
> +
> +	public void modifyPolicy(String name, String policyString) throws  
> SPLException {
> +
> +		
> +		_policyManager.updatePolicy(name,policyString);
> +
> +
> +	}
> +
> +	public Object executePolicy(String policyName, Map  
> instanceObjectMap) throws SPLException
> +	{
> +	
> +
> +		Object retVal = _policyManager.evaluatePolicy 
> (policyName,instanceObjectMap);
> +
> +
> +		return retVal;
> +	}
> +	
> +	public static void main(String [] args)
> +	{
> +		
> +
> +	}
> +
> +}
>
> Propchange: incubator/imperius/trunk/imperius-javaspl/src/main/java/ 
> org/apache/imperius/javaspl/Java_SPLPolicyRuleProvider.java
> ---------------------------------------------------------------------- 
> --------
>     svn:eol-style = native
>
> Modified: incubator/imperius/trunk/imperius-splcore/pom.xml
> URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius- 
> splcore/pom.xml?rev=611261&r1=611260&r2=611261&view=diff
> ====================================================================== 
> ========
> --- incubator/imperius/trunk/imperius-splcore/pom.xml (original)
> +++ incubator/imperius/trunk/imperius-splcore/pom.xml Fri Jan 11  
> 10:56:30 2008
> @@ -1,64 +1,64 @@
> -<!--
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - *      http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing,  
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> - * See the License for the specific language governing permissions  
> and
> - * limitations under the License.
> - */-->
> -<project xmlns="http://maven.apache.org/POM/4.0.0"  
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> -  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http:// 
> maven.apache.org/maven-v4_0_0.xsd">
> -  <modelVersion>4.0.0</modelVersion>
> -  <groupId>imperius</groupId>
> -  <artifactId>imperius-splcore</artifactId>
> -  <packaging>jar</packaging>
> -  <version>1.0.0-SNAPSHOT</version>
> -  <name>imperius-splcore</name>
> -  <url>http://incubator.apache.org/imperius</url>
> -  <dependencies>
> -  <dependency>
> -	<groupId>antlr</groupId>
> -	<artifactId>antlr</artifactId>
> -	<version>2.7.7</version>
> -    </dependency>
> -    <dependency>
> -      <groupId>junit</groupId>
> -      <artifactId>junit</artifactId>
> -      <version>3.8.1</version>
> -
> -    </dependency>
> -  </dependencies>
> -
> -   <build>
> -    <plugins>
> -       <plugin>
> -        <groupId>org.codehaus.mojo</groupId>
> -        <artifactId>antlr-maven-plugin</artifactId>
> -        <configuration>
> -          <!--
> -            Comma separated list of grammar files or pattern  
> grammar files
> -            By default, grammar file(s) is in ${basedir}/src/main/ 
> antlr
> -            <grammars>*.g</grammars>
> -          -->
> -
> -          <grammars>/org/apache/imperius/spl/parser/compiler/ 
> cimspl.g,/org/apache/imperius/spl/parser/compiler/cimspl.tree.g</ 
> grammars>
> -          <!-- <grammars>*.g</grammars> -->
> -        </configuration>
> -        <executions>
> -          <execution>
> -            <goals>
> -              <goal>generate</goal>
> -            </goals>
> -          </execution>
> -        </executions>
> -      </plugin>
> -
> -    </plugins>
> -  </build>
> -
> -</project>
> +<!--
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> + */-->
> +<project xmlns="http://maven.apache.org/POM/4.0.0"  
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> +  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http:// 
> maven.apache.org/maven-v4_0_0.xsd">
> +  <modelVersion>4.0.0</modelVersion>
> +  <groupId>imperius</groupId>
> +  <artifactId>imperius-splcore</artifactId>
> +  <packaging>jar</packaging>
> +  <version>1.0.0-SNAPSHOT</version>
> +  <name>imperius-splcore</name>
> +  <url>http://incubator.apache.org/imperius</url>
> +  <dependencies>
> +  <dependency>
> +	<groupId>antlr</groupId>
> +	<artifactId>antlr</artifactId>
> +	<version>2.7.7</version>
> +    </dependency>
> +    <dependency>
> +      <groupId>junit</groupId>
> +      <artifactId>junit</artifactId>
> +      <version>3.8.1</version>
> +
> +    </dependency>
> +  </dependencies>
> +
> +   <build>
> +    <plugins>
> +       <plugin>
> +        <groupId>org.codehaus.mojo</groupId>
> +        <artifactId>antlr-maven-plugin</artifactId>
> +        <configuration>
> +          <!--
> +            Comma separated list of grammar files or pattern  
> grammar files
> +            By default, grammar file(s) is in ${basedir}/src/main/ 
> antlr
> +            <grammars>*.g</grammars>
> +          -->
> +
> +          <grammars>/org/apache/imperius/spl/parser/compiler/ 
> cimspl.g,/org/apache/imperius/spl/parser/compiler/cimspl.tree.g</ 
> grammars>
> +          <!-- <grammars>*.g</grammars> -->
> +        </configuration>
> +        <executions>
> +          <execution>
> +            <goals>
> +              <goal>generate</goal>
> +            </goals>
> +          </execution>
> +        </executions>
> +      </plugin>
> +
> +    </plugins>
> +  </build>
> +
> +</project>
>
> Propchange: incubator/imperius/trunk/imperius-splcore/pom.xml
> ---------------------------------------------------------------------- 
> --------
>     svn:eol-style = native
>
> Modified: incubator/imperius/trunk/imperius-splcore/src/main/antlr/ 
> org/apache/imperius/spl/parser/compiler/cimspl.g
> URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius- 
> splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/ 
> cimspl.g?rev=611261&r1=611260&r2=611261&view=diff
> ====================================================================== 
> ========
> --- incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/ 
> apache/imperius/spl/parser/compiler/cimspl.g (original)
> +++ incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/ 
> apache/imperius/spl/parser/compiler/cimspl.g Fri Jan 11 10:56:30 2008
> @@ -1,534 +1,534 @@
> -/*
> - * Copyright 2007 The Apache Software Foundation.
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - *      http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing,  
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> - * See the License for the specific language governing permissions  
> and
> - * limitations under the License.
> - */
> -
> -// * @author Neeraj Joshi <jneeraj@us.ibm.com>
> -
> -
> -  header {
> -  	/*
> - * Copyright 2007 The Apache Software Foundation.
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - *      http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing,  
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> - * See the License for the specific language governing permissions  
> and
> - * limitations under the License.
> - */
> -
> -	/**
> -	 * @author Neeraj Joshi <jneeraj@us.ibm.com>
> -	 *
> -	 */
> -  package org.apache.imperius.spl.parser.compiler;
> -  }
> -options {
> -    language=Java;
> -}
> -class SPLParser extends Parser;
> -options {
> -    exportVocab=cimspl;
> -    genHashLines = true;        // include line number information
> -     
> ASTLabelType="org.apache.imperius.spl.parser.compiler.ASTWithLineNumbe 
> r";
> -    buildAST = true;
> -    k = 1;          // uses CommonAST by default
> -}
> -
> -tokens {
> -	STRATEGY_DEF; IMPORT_DEF; DECL_DEF; CONSTANT_DEFN; MACRO_DEFN;  
> POLICY_DEF; CONDITION_DEF;
> -	POLICY_GRP_DEF; DECISION_DEF; TYPE; ARGUMENTS; ARG_DEF;
> -	EXPR; ELIST; METHOD_CALL; UNARY_MINUS; QUALIFIER;
> -	PARAMETERS; PARAMETER_DEF; UNARY_PLUS; ARRAY_DECLARATOR;  
> INDEX_OP; COLLECT_OP ;ASSOCIATION;
> -        ACTIONBLOCK; COLLECT_CALL ; UNARY_NOT;BASICCOLLECTION_OP;
> -
> -
> -
> -
> -}
> -
> -
> -splpolicy :
> -        (importstatement)+ strategystatement declarationstatement  
> (policystatement)+
> -;
> -
> -importstatement :
> -  //      i:"Import"^ {#i.setType(IMPORT_DEF);} IDENT (DOT! IDENT) 
> * (COMMA! IDENT (DOT! IDENT)*)* (expression)? SEMI!
> -      i:"Import"^ {#i.setType(IMPORT_DEF);}(qualifier)? "Class"!   
> IDENT (DOT! IDENT)*  (identList)? (expression)?  SEMI!
> -;
> -
> -qualifier :
> -	q:"Qualifier"^  {#q.setType(QUALIFIER);} IDENT
> -;
> -
> -identList :
> -	c:COLON^ IDENT (COMMA! IDENT)*
> -;
> -
> -strategystatement :
> -        s:"Strategy"^ {#s.setType(STRATEGY_DEF);} 
> ("Execute_All_Applicable" | "Execute_First_Applicable")  SEMI!
> -;
> -
> -declarationstatement :
> -(d:"Declaration"^ {#d.setType(DECL_DEF);} LCURLY!  
> ((constantDefinitions) | (macroDeclarations))* RCURLY! )?
> -        ;
> -
> -constantDefinitions ! :
> -		id:IDENT v:varInitializer SEMI!
> -		{#constantDefinitions = #(#[CONSTANT_DEFN,"CONSTANT_DEFN"],id,v);}
> -
> -;
> -
> -varInitializer :
> -        ( ASSIGN^ expression )?
> -;
> -
> -
> -macroDeclarations !:
> -        "Macro"! LCURLY! m:macrodef RCURLY!
> -        {#macroDeclarations = #(#[MACRO_DEFN,"MACRO"],m);}
> -;
> -macrodef :
> -        "Name"^ ASSIGN! id:IDENT SEMI!
> -        "type"! ASSIGN! splType SEMI!
> -         argumentList
> -        "procedure"! ASSIGN! expression
> - ;
> -argumentList  :
> -        ("argument"! ASSIGN! argument (COMMA! argument)* SEMI!)?
> -        	{#argumentList = #(#[ARGUMENTS,"ARGUMENTS"],
> -									#argumentList);}
> -;
> -
> -argument ! :
> -            id:IDENT COLON! c:splType
> -        	{#argument = #(#[ARG_DEF,"ARG_DEF"],  #([TYPE,"TYPE"],c),  
> id);}
> -;
> -
> -
> -policystatement :
> -        (policydef | policyGroup)   SEMI!
> -;
> -
> -
> -policydef :
> -        p:"Policy"^ {#p.setType(POLICY_DEF);} LCURLY!  
> declarationstatement conditionstatement decision RCURLY! COLON!  
> priority
> -;
> -
> -conditionstatement :
> -        (c:"Condition"^ {#c.setType(CONDITION_DEF);} LCURLY!  
> expression RCURLY!)?
> -;
> -decision :
> -        d:"Decision"^ {#d.setType(DECISION_DEF);}  LCURLY!  
> actionBlock RCURLY!
> -;
> -
> -priority :
> -        NUM_INT
> -;
> -expression :
> -        assignmentExpression
> -        {#expression = #(#[EXPR,"EXPR"],#expression);}
> -;
> -
> -exprList :
> -        expression (COMMA! expression)*
> -        {#exprList = #(#[ELIST,"ELIST"], exprList);}
> -;
> -
> -assignmentExpression :
> -        conditionalExpression
> -        (
> -                ASSIGN^ assignmentExpression
> -        )?
> -;
> -
> -
> -conditionalExpression :
> -        logicalOrexpression
> -;
> -logicalOrexpression :
> -        logicalAndExpression (LOR^ logicalAndExpression)*
> -;
> -
> -logicalAndExpression  :
> -          exclusiveOrExpression (LAND^ exclusiveOrExpression)*
> -;
> -
> -exclusiveOrExpression :
> -          equalityExpression (BXOR^ equalityExpression)*
> -;
> -
> -equalityExpression :
> -        relationalExpression ((NOT_EQUAL^ | EQUAL^)  
> relationalExpression)*
> -;
> -
> -relationalExpression :
> -        additiveExpression (( LT^ | GT^ | LE^ | GE^ )  
> additiveExpression)*
> -;
> -
> -additiveExpression :
> -        multiplicativeExpression ((PLUS^ | MINUS^)  
> multiplicativeExpression)*
> -;
> -
> -
> -// multiplication/division (level 2)
> -multiplicativeExpression :
> -		
> -           unaryExpression ((STAR^ | DIV^ ) unaryExpression)*
> -;
> -
> -unaryExpression :
> -          (MINUS^ {#MINUS.setType(UNARY_MINUS);}  
> unaryExpression )| (PLUS^ {#PLUS.setType(UNARY_PLUS);}  
> unaryExpression) | (unaryExpressionNotPlusMinus)
> -;
> -
> -unaryExpressionNotPlusMinus :
> -        (LNOT^ {#LNOT.setType(UNARY_NOT);} unaryExpression )|  
> (primaryExpression)
> -;
> -
> -
> -
> -primaryExpression :
> -        identPrimary | constant | "true"| "false" | "Self"  |  
> (LPAREN! assignmentExpression RPAREN!)
> -;
> -
> -identPrimary :
> -                IDENT^ ( (DOT! IDENT (indexOp | methodCall)?)* |  
> methodCall)
> -                | collectOperation
> -                | basicCollectionOp
> -                  ;
> -
> -collectOperation :
> -                 c:"collect"^ {#c.setType(COLLECT_OP);}  
> collectmethodcall (indexOp (methodOrPropertyOrArrayForCollect)? )?
> -                 ;
> -
> -collectmethodcall :
> -
> -LPAREN^ {#LPAREN.setType(COLLECT_CALL); }  paramList RPAREN!
> -;
> -
> -methodOrPropertyOrArrayForCollect :     DOT! IDENT ( indexOp |  
> methodCall)?
> -
> -                                        ;
> -
> -
> -
> -indexOp : lb:LBRACK^ {#lb.setType(INDEX_OP);} expression RBRACK!
> -;
> -
> -basicCollectionOp : lb:LBRACK^ {#lb.setType(BASICCOLLECTION_OP);}  
> exprList RBRACK!
> -;
> -
> -methodCall :   lp:LPAREN^ {#lp.setType(METHOD_CALL);} paramList  
> RPAREN!
> -
> -                ;
> -
> -constant :
> -		// DATE_TIME
> -		//|
> -		NUM_INT
> -        |   CHAR_LITERAL
> -        |   STRING_LITERAL
> -        |   NUM_FLOAT
> -        |   NUM_LONG
> -        |   NUM_DOUBLE
> -
> -
> -;
> -
> -//dateTime : NUM_INT DOT NUM_INT ( (PLUS | MINUS) NUM_INT | COLON  
> NUM_INT)
> -       //   ;
> -
> -paramList :
> -        (exprList)?
> -;
> -
> -
> -actionBlock :
> -             actionBlockExpr ( (ARROW^ | LAND^ | LOR^ | BOR^)  
> actionBlockExpr)*
> -       ;
> -actionBlockExpr :
> -                basicActionBlock | LPAREN! actionBlock RPAREN!
> -                ;
> -
> -
> -basicActionBlock :
> -                (IDENT | "Set" | "InvokePolicy" ) (DOT! IDENT)?  
> (methodCall) ((EQUAL | NOT_EQUAL | GE | GT | LT | LE) constant)?
> -                {#basicActionBlock = #(# 
> [ACTIONBLOCK,"ACTIONBLK"],basicActionBlock );}
> -
> -;
> -
> -policyGroup :
> -        p:"PolicyGroup"^ {#p.setType(POLICY_GRP_DEF);} assocName  
> LCURLY! splpolicy RCURLY! COLON! priority
> -;
> -
> -assocName :
> -        COLON! IDENT^ LPAREN! IDENT COMMA! IDENT RPAREN!
> -         {#assocName = #(#[ASSOCIATION,"ASSOC"], assocName);}
> -         ;
> -
> -splType :
> -	 basicSplTypes (LBRACK RBRACK)?
> -
> -        ;
> -
> -basicSplTypes :
> -"Sint8" | "Sint16" | "Uint8" | "Uint16" |
> - "Sint32" | "Sint64" | "Uint32" | "Uint64" |
> -    "Real32" | "Real64" | "Boolean" | "Char16"|
> -     "String" | "DateTime" | "Reference"
> -;
> -
> -
> -class SPLLexer extends Lexer;
> -
> -options {
> -    exportVocab=cimspl;      // call the vocabulary "Java"
> -    testLiterals=false;    // don't automatically test for literals
> -    k=4;                   // four characters of lookahead
> -    // can't deal with 16 bit chars
> -
> -    charVocabulary='\u0003'..'\u00FF';
> -
> -}
> -
> -// OPERATORS
> -
> -LPAREN      :   '('     ;
> -RPAREN      :   ')'     ;
> -LBRACK      :   '['     ;
> -RBRACK      :   ']'     ;
> -LCURLY      :   '{'     ;
> -RCURLY      :   '}'     ;
> -COLON       :   ':'     ;
> -COMMA       :   ','     ;
> -DOT		    :	'.'		;
> -ASSIGN      :   '='     ;
> -EQUAL       :   "=="    ;
> -LNOT        :   '!'     ;
> -NOT_EQUAL   :   "!="    ;
> -DIV     :   '/'     ;
> -PLUS        :   '+'     ;
> -MINUS       :   '-'     ;
> -//DATE_TIME   : (('0'..'9'|'*') ('0'..'9'|'*')('0'..'9'|'*') 
> ('0'..'9'|'*')('0'..'1'|'*')('0'..'9'|'*')('0'..'3'|'*') 
> ('0'..'9'|'*')('0'..'6'|'*')('0'..'9'|'*')('0'..'6'|'*') 
> ('0'..'9'|'*')('0'..'6'|'*')('0'..'9'|'*')('.')('0'..'9'|'*') 
> ('0'..'9'|'*')('0'..'9'|'*')('0'..'9'|'*')('0'..'9'|'*') 
> ('0'..'9'|'*')(PLUS|MINUS|':')('0'..'9'|'*')('0'..'9'|'*') 
> ('0'..'9'|'*')){_ttype = DATE_TIME;}
> -			
> -// ;
> -STAR        :   '*'     ;
> -GE      :   ">="    ;
> -GT      :   ">"     ;
> -LE      :   "<="    ;
> -LT     :   '<'     ;
> -BXOR        :   '^'     ;
> -BOR     :   '|'
> -   ;
> -LOR     :   "||"    ;
> -LAND        :   "&&"    ;
> -SEMI        :   ';'     ;
> -ARROW   : "->";
> -          // Whitespace -- ignored
> -WS	:	(	' '
> -		|	'\t'
> -		|	'\f'
> -			// handle newlines
> -		|	(	options {generateAmbigWarnings=false;}
> -			:	"\r\n"  // Evil DOS
> -			|	'\r'    // Macintosh
> -			|	'\n'    // Unix (the right way)
> -			)
> -			{ newline(); }
> -		)+
> -		{ _ttype = Token.SKIP; }
> -	;
> -
> -// Single-line comments
> -SL_COMMENT
> -	:	"//"
> -		(~('\n'|'\r'))* ('\n'|'\r'('\n')?)?
> -		{$setType(Token.SKIP); newline();}
> -	;
> -
> -// multiple-line comments
> -ML_COMMENT
> -	:	"/*"
> -		(	/*	'\r' '\n' can be matched in one alternative or by matching
> -				'\r' in one iteration and '\n' in another.  I am trying to
> -				handle any flavor of newline that comes in, but the language
> -				that allows both "\r\n" and "\r" and "\n" to all be valid
> -				newline is ambiguous.  Consequently, the resulting grammar
> -				must be ambiguous.  I'm shutting this warning off.
> -			 */
> -			options {
> -				generateAmbigWarnings=false;
> -			}
> -		:
> -			{ LA(2)!='/' }? '*'
> -		|	'\r' '\n'		{newline();}
> -		|	'\r'			{newline();}
> -		|	'\n'			{newline();}
> -		|	~('*'|'\n'|'\r')
> -		)*
> -		"*/"
> -		{$setType(Token.SKIP);}
> -	;
> -
> -
> -// character literals
> -CHAR_LITERAL
> -	:	'\'' ( ESC | ~('\''|'\n'|'\r'|'\\') ) '\''
> -	;
> -
> -// string literals
> -STRING_LITERAL
> -	:	'"' (ESC|~('"'|'\\'|'\n'|'\r'))* '"'
> -	;
> -
> -
> -
> -// escape sequence -- note that this is protected; it can only be  
> called
> -//   from another lexer rule -- it will not ever directly return a  
> token to
> -//   the parser
> -// There are various ambiguities hushed in this rule.  The optional
> -// '0'...'9' digit matches should be matched here rather than letting
> -// them go back to STRING_LITERAL to be matched.  ANTLR does the
> -// right thing by matching immediately; hence, it's ok to shut off
> -// the FOLLOW ambig warnings.
> -protected
> -ESC
> -	:	'\\'
> -		(	'n'
> -		|	'r'
> -		|	't'
> -		|	'b'
> -		|	'f'
> -		|	'"'
> -		|	'\''
> -		|	'\\'
> -		|	('u')+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
> -		|	'0'..'3'
> -			(
> -				options {
> -					warnWhenFollowAmbig = false;
> -				}
> -			:	'0'..'7'
> -				(
> -					options {
> -						warnWhenFollowAmbig = false;
> -					}
> -				:	'0'..'7'
> -				)?
> -			)?
> -		|	'4'..'7'
> -			(
> -				options {
> -					warnWhenFollowAmbig = false;
> -				}
> -			:	'0'..'7'
> -			)?
> -		)
> -	;
> -
> -
> -// hexadecimal digit (again, note it's protected!)
> -protected
> -HEX_DIGIT
> -	:	('0'..'9'|'A'..'F'|'a'..'f')
> -	;
> -
> -
> -// an identifier.  Note that testLiterals is set to true!  This means
> -// that after we match the rule, we look in the literals table to see
> -// if it's a literal or really an identifer
> -IDENT
> -	options {testLiterals=true;}
> -	:	('a'..'z'|'A'..'Z'|'_'|'$')  
> ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'$'|'/')*
> -	;
> -
> -//DATE_TIME
> - //  : ('0'..'9'|STAR) ('0'..'9'|STAR)('0'..'9'|STAR)('0'..'9'| 
> STAR)('0'..'1'|STAR)('0'..'9'|STAR)('0'..'3'|STAR)('0'..'9'|STAR) 
> ('0'..'6'|STAR)('0'..'9'|STAR)('0'..'6'|STAR)('0'..'9'|STAR) 
> ('0'..'6'|STAR)('0'..'9'|STAR)(DOT)('0'..'9'|STAR)('0'..'9'|STAR) 
> ('0'..'9'|STAR)('0'..'9'|STAR)('0'..'9'|STAR)('0'..'9'|STAR)(PLUS| 
> MINUS)('0'..'9'|STAR)('0'..'9'|STAR)('0'..'9'|STAR){_ttype =  
> DATE_TIME;}
> - //
> -//	 ;
> -// a numeric literal
> -NUM_INT
> -	{boolean isDecimal=false; Token t=null;}
> -    :   '.' {_ttype = DOT;}
> -            (	('0'..'9')+ (EXPONENT)? (f1:FLOAT_SUFFIX {t=f1;})?
> -                {
> -				if (t != null && t.getText().toUpperCase().indexOf('F')>=0) {
> -                	_ttype = NUM_FLOAT;
> -				}
> -				else {
> -                	_ttype = NUM_DOUBLE; // assume double
> -				}
> -				}
> -            )?
> -
> -	|	(	'0' {isDecimal = true;} // special case for just '0'
> -			(	('x'|'X')
> -				(											// hex
> -					// the 'e'|'E' and float suffix stuff look
> -					// like hex digits, hence the (...)+ doesn't
> -					// know when to stop: ambig.  ANTLR resolves
> -					// it correctly by matching immediately.  It
> -					// is therefor ok to hush warning.
> -					options {
> -						warnWhenFollowAmbig=false;
> -					}
> -				:	HEX_DIGIT
> -				)+
> -
> -			|	//float or double with leading zero
> -				(('0'..'9')+ ('.'|EXPONENT|FLOAT_SUFFIX)) => ('0'..'9')+
> -
> -			|	('0'..'7')+									// octal
> -			)?
> -		|	('1'..'9') ('0'..'9')*  {isDecimal=true;}		// non-zero decimal
> -		)
> -		(	('l'|'L') { _ttype = NUM_LONG; }
> -
> -		// only check to see if it's a float if looks like decimal so far
> -		|	{isDecimal}?
> -            (   '.' ('0'..'9')* (EXPONENT)? (f2:FLOAT_SUFFIX  
> {t=f2;})?
> -            |   EXPONENT (f3:FLOAT_SUFFIX {t=f3;})?
> -            |   f4:FLOAT_SUFFIX {t=f4;}
> -            )
> -            {
> -			if (t != null && t.getText().toUpperCase() .indexOf('F') >= 0) {
> -                _ttype = NUM_FLOAT;
> -			}
> -            else {
> -	           	_ttype = NUM_DOUBLE; // assume double
> -			}
> -			}
> -        )?
> -	;
> -
> -
> -// a couple protected methods to assist in matching floating point  
> numbers
> -protected
> -EXPONENT
> -	:	('e'|'E') ('+'|'-')? ('0'..'9')+
> -	;
> -
> -
> -protected
> -FLOAT_SUFFIX
> -	:	'f'|'F'|'d'|'D'
> -	;
> -
> -
> +/*
> + * Copyright 2007 The Apache Software Foundation.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> + */
> +
> +// * @author Neeraj Joshi <jneeraj@us.ibm.com>
> +
> +
> +  header {
> +  	/*
> + * Copyright 2007 The Apache Software Foundation.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> + */
> +
> +	/**
> +	 * @author Neeraj Joshi <jneeraj@us.ibm.com>
> +	 *
> +	 */
> +  package org.apache.imperius.spl.parser.compiler;
> +  }
> +options {
> +    language=Java;
> +}
> +class SPLParser extends Parser;
> +options {
> +    exportVocab=cimspl;
> +    genHashLines = true;        // include line number information
> +     
> ASTLabelType="org.apache.imperius.spl.parser.compiler.ASTWithLineNumbe 
> r";
> +    buildAST = true;
> +    k = 1;          // uses CommonAST by default
> +}
> +
> +tokens {
> +	STRATEGY_DEF; IMPORT_DEF; DECL_DEF; CONSTANT_DEFN; MACRO_DEFN;  
> POLICY_DEF; CONDITION_DEF;
> +	POLICY_GRP_DEF; DECISION_DEF; TYPE; ARGUMENTS; ARG_DEF;
> +	EXPR; ELIST; METHOD_CALL; UNARY_MINUS; QUALIFIER;
> +	PARAMETERS; PARAMETER_DEF; UNARY_PLUS; ARRAY_DECLARATOR;  
> INDEX_OP; COLLECT_OP ;ASSOCIATION;
> +        ACTIONBLOCK; COLLECT_CALL ; UNARY_NOT;BASICCOLLECTION_OP;
> +
> +
> +
> +
> +}
> +
> +
> +splpolicy :
> +        (importstatement)+ strategystatement declarationstatement  
> (policystatement)+
> +;
> +
> +importstatement :
> +  //      i:"Import"^ {#i.setType(IMPORT_DEF);} IDENT (DOT! IDENT) 
> * (COMMA! IDENT (DOT! IDENT)*)* (expression)? SEMI!
> +      i:"Import"^ {#i.setType(IMPORT_DEF);}(qualifier)? "Class"!   
> IDENT (DOT! IDENT)*  (identList)? (expression)?  SEMI!
> +;
> +
> +qualifier :
> +	q:"Qualifier"^  {#q.setType(QUALIFIER);} IDENT
> +;
> +
> +identList :
> +	c:COLON^ IDENT (COMMA! IDENT)*
> +;
> +
> +strategystatement :
> +        s:"Strategy"^ {#s.setType(STRATEGY_DEF);} 
> ("Execute_All_Applicable" | "Execute_First_Applicable")  SEMI!
> +;
> +
> +declarationstatement :
> +(d:"Declaration"^ {#d.setType(DECL_DEF);} LCURLY!  
> ((constantDefinitions) | (macroDeclarations))* RCURLY! )?
> +        ;
> +
> +constantDefinitions ! :
> +		id:IDENT v:varInitializer SEMI!
> +		{#constantDefinitions = #(#[CONSTANT_DEFN,"CONSTANT_DEFN"],id,v);}
> +
> +;
> +
> +varInitializer :
> +        ( ASSIGN^ expression )?
> +;
> +
> +
> +macroDeclarations !:
> +        "Macro"! LCURLY! m:macrodef RCURLY!
> +        {#macroDeclarations = #(#[MACRO_DEFN,"MACRO"],m);}
> +;
> +macrodef :
> +        "Name"^ ASSIGN! id:IDENT SEMI!
> +        "type"! ASSIGN! splType SEMI!
> +         argumentList
> +        "procedure"! ASSIGN! expression
> + ;
> +argumentList  :
> +        ("argument"! ASSIGN! argument (COMMA! argument)* SEMI!)?
> +        	{#argumentList = #(#[ARGUMENTS,"ARGUMENTS"],
> +									#argumentList);}
> +;
> +
> +argument ! :
> +            id:IDENT COLON! c:splType
> +        	{#argument = #(#[ARG_DEF,"ARG_DEF"],  #([TYPE,"TYPE"],c),  
> id);}
> +;
> +
> +
> +policystatement :
> +        (policydef | policyGroup)   SEMI!
> +;
> +
> +
> +policydef :
> +        p:"Policy"^ {#p.setType(POLICY_DEF);} LCURLY!  
> declarationstatement conditionstatement decision RCURLY! COLON!  
> priority
> +;
> +
> +conditionstatement :
> +        (c:"Condition"^ {#c.setType(CONDITION_DEF);} LCURLY!  
> expression RCURLY!)?
> +;
> +decision :
> +        d:"Decision"^ {#d.setType(DECISION_DEF);}  LCURLY!  
> actionBlock RCURLY!
> +;
> +
> +priority :
> +        NUM_INT
> +;
> +expression :
> +        assignmentExpression
> +        {#expression = #(#[EXPR,"EXPR"],#expression);}
> +;
> +
> +exprList :
> +        expression (COMMA! expression)*
> +        {#exprList = #(#[ELIST,"ELIST"], exprList);}
> +;
> +
> +assignmentExpression :
> +        conditionalExpression
> +        (
> +                ASSIGN^ assignmentExpression
> +        )?
> +;
> +
> +
> +conditionalExpression :
> +        logicalOrexpression
> +;
> +logicalOrexpression :
> +        logicalAndExpression (LOR^ logicalAndExpression)*
> +;
> +
> +logicalAndExpression  :
> +          exclusiveOrExpression (LAND^ exclusiveOrExpression)*
> +;
> +
> +exclusiveOrExpression :
> +          equalityExpression (BXOR^ equalityExpression)*
> +;
> +
> +equalityExpression :
> +        relationalExpression ((NOT_EQUAL^ | EQUAL^)  
> relationalExpression)*
> +;
> +
> +relationalExpression :
> +        additiveExpression (( LT^ | GT^ | LE^ | GE^ )  
> additiveExpression)*
> +;
> +
> +additiveExpression :
> +        multiplicativeExpression ((PLUS^ | MINUS^)  
> multiplicativeExpression)*
> +;
> +
> +
> +// multiplication/division (level 2)
> +multiplicativeExpression :
> +		
> +           unaryExpression ((STAR^ | DIV^ ) unaryExpression)*
> +;
> +
> +unaryExpression :
> +          (MINUS^ {#MINUS.setType(UNARY_MINUS);}  
> unaryExpression )| (PLUS^ {#PLUS.setType(UNARY_PLUS);}  
> unaryExpression) | (unaryExpressionNotPlusMinus)
> +;
> +
> +unaryExpressionNotPlusMinus :
> +        (LNOT^ {#LNOT.setType(UNARY_NOT);} unaryExpression )|  
> (primaryExpression)
> +;
> +
> +
> +
> +primaryExpression :
> +        identPrimary | constant | "true"| "false" | "Self"  |  
> (LPAREN! assignmentExpression RPAREN!)
> +;
> +
> +identPrimary :
> +                IDENT^ ( (DOT! IDENT (indexOp | methodCall)?)* |  
> methodCall)
> +                | collectOperation
> +                | basicCollectionOp
> +                  ;
> +
> +collectOperation :
> +                 c:"collect"^ {#c.setType(COLLECT_OP);}  
> collectmethodcall (indexOp (methodOrPropertyOrArrayForCollect)? )?
> +                 ;
> +
> +collectmethodcall :
> +
> +LPAREN^ {#LPAREN.setType(COLLECT_CALL); }  paramList RPAREN!
> +;
> +
> +methodOrPropertyOrArrayForCollect :     DOT! IDENT ( indexOp |  
> methodCall)?
> +
> +                                        ;
> +
> +
> +
> +indexOp : lb:LBRACK^ {#lb.setType(INDEX_OP);} expression RBRACK!
> +;
> +
> +basicCollectionOp : lb:LBRACK^ {#lb.setType(BASICCOLLECTION_OP);}  
> exprList RBRACK!
> +;
> +
> +methodCall :   lp:LPAREN^ {#lp.setType(METHOD_CALL);} paramList  
> RPAREN!
> +
> +                ;
> +
> +constant :
> +		// DATE_TIME
> +		//|
> +		NUM_INT
> +        |   CHAR_LITERAL
> +        |   STRING_LITERAL
> +        |   NUM_FLOAT
> +        |   NUM_LONG
> +        |   NUM_DOUBLE
> +
> +
> +;
> +
> +//dateTime : NUM_INT DOT NUM_INT ( (PLUS | MINUS) NUM_INT | COLON  
> NUM_INT)
> +       //   ;
> +
> +paramList :
> +        (exprList)?
> +;
> +
> +
> +actionBlock :
> +             actionBlockExpr ( (ARROW^ | LAND^ | LOR^ | BOR^)  
> actionBlockExpr)*
> +       ;
> +actionBlockExpr :
> +                basicActionBlock | LPAREN! actionBlock RPAREN!
> +                ;
> +
> +
> +basicActionBlock :
> +                (IDENT | "Set" | "InvokePolicy" ) (DOT! IDENT)?  
> (methodCall) ((EQUAL | NOT_EQUAL | GE | GT | LT | LE) constant)?
> +                {#basicActionBlock = #(# 
> [ACTIONBLOCK,"ACTIONBLK"],basicActionBlock );}
> +
> +;
> +
> +policyGroup :
> +        p:"PolicyGroup"^ {#p.setType(POLICY_GRP_DEF);} assocName  
> LCURLY! splpolicy RCURLY! COLON! priority
> +;
> +
> +assocName :
> +        COLON! IDENT^ LPAREN! IDENT COMMA! IDENT RPAREN!
> +         {#assocName = #(#[ASSOCIATION,"ASSOC"], assocName);}
> +         ;
> +
> +splType :
> +	 basicSplTypes (LBRACK RBRACK)?
> +
> +        ;
> +
> +basicSplTypes :
> +"Sint8" | "Sint16" | "Uint8" | "Uint16" |
> + "Sint32" | "Sint64" | "Uint32" | "Uint64" |
> +    "Real32" | "Real64" | "Boolean" | "Char16"|
> +     "String" | "DateTime" | "Reference"
> +;
> +
> +
> +class SPLLexer extends Lexer;
> +
> +options {
> +    exportVocab=cimspl;      // call the vocabulary "Java"
> +    testLiterals=false;    // don't automatically test for literals
> +    k=4;                   // four characters of lookahead
> +    // can't deal with 16 bit chars
> +
> +    charVocabulary='\u0003'..'\u00FF';
> +
> +}
> +
> +// OPERATORS
> +
> +LPAREN      :   '('     ;
> +RPAREN      :   ')'     ;
> +LBRACK      :   '['     ;
> +RBRACK      :   ']'     ;
> +LCURLY      :   '{'     ;
> +RCURLY      :   '}'     ;
> +COLON       :   ':'     ;
> +COMMA       :   ','     ;
> +DOT		    :	'.'		;
> +ASSIGN      :   '='     ;
> +EQUAL       :   "=="    ;
> +LNOT        :   '!'     ;
> +NOT_EQUAL   :   "!="    ;
> +DIV     :   '/'     ;
> +PLUS        :   '+'     ;
> +MINUS       :   '-'     ;
> +//DATE_TIME   : (('0'..'9'|'*') ('0'..'9'|'*')('0'..'9'|'*') 
> ('0'..'9'|'*')('0'..'1'|'*')('0'..'9'|'*')('0'..'3'|'*') 
> ('0'..'9'|'*')('0'..'6'|'*')('0'..'9'|'*')('0'..'6'|'*') 
> ('0'..'9'|'*')('0'..'6'|'*')('0'..'9'|'*')('.')('0'..'9'|'*') 
> ('0'..'9'|'*')('0'..'9'|'*')('0'..'9'|'*')('0'..'9'|'*') 
> ('0'..'9'|'*')(PLUS|MINUS|':')('0'..'9'|'*')('0'..'9'|'*') 
> ('0'..'9'|'*')){_ttype = DATE_TIME;}
> +			
> +// ;
> +STAR        :   '*'     ;
> +GE      :   ">="    ;
> +GT      :   ">"     ;
> +LE      :   "<="    ;
> +LT     :   '<'     ;
> +BXOR        :   '^'     ;
> +BOR     :   '|'
> +   ;
> +LOR     :   "||"    ;
> +LAND        :   "&&"    ;
> +SEMI        :   ';'     ;
> +ARROW   : "->";
> +          // Whitespace -- ignored
> +WS	:	(	' '
> +		|	'\t'
> +		|	'\f'
> +			// handle newlines
> +		|	(	options {generateAmbigWarnings=false;}
> +			:	"\r\n"  // Evil DOS
> +			|	'\r'    // Macintosh
> +			|	'\n'    // Unix (the right way)
> +			)
> +			{ newline(); }
> +		)+
> +		{ _ttype = Token.SKIP; }
> +	;
> +
> +// Single-line comments
> +SL_COMMENT
> +	:	"//"
> +		(~('\n'|'\r'))* ('\n'|'\r'('\n')?)?
> +		{$setType(Token.SKIP); newline();}
> +	;
> +
> +// multiple-line comments
> +ML_COMMENT
> +	:	"/*"
> +		(	/*	'\r' '\n' can be matched in one alternative or by matching
> +				'\r' in one iteration and '\n' in another.  I am trying to
> +				handle any flavor of newline that comes in, but the language
> +				that allows both "\r\n" and "\r" and "\n" to all be valid
> +				newline is ambiguous.  Consequently, the resulting grammar
> +				must be ambiguous.  I'm shutting this warning off.
> +			 */
> +			options {
> +				generateAmbigWarnings=false;
> +			}
> +		:
> +			{ LA(2)!='/' }? '*'
> +		|	'\r' '\n'		{newline();}
> +		|	'\r'			{newline();}
> +		|	'\n'			{newline();}
> +		|	~('*'|'\n'|'\r')
> +		)*
> +		"*/"
> +		{$setType(Token.SKIP);}
> +	;
> +
> +
> +// character literals
> +CHAR_LITERAL
> +	:	'\'' ( ESC | ~('\''|'\n'|'\r'|'\\') ) '\''
> +	;
> +
> +// string literals
> +STRING_LITERAL
> +	:	'"' (ESC|~('"'|'\\'|'\n'|'\r'))* '"'
> +	;
> +
> +
> +
> +// escape sequence -- note that this is protected; it can only be  
> called
> +//   from another lexer rule -- it will not ever directly return a  
> token to
> +//   the parser
> +// There are various ambiguities hushed in this rule.  The optional
> +// '0'...'9' digit matches should be matched here rather than letting
> +// them go back to STRING_LITERAL to be matched.  ANTLR does the
> +// right thing by matching immediately; hence, it's ok to shut off
> +// the FOLLOW ambig warnings.
> +protected
> +ESC
> +	:	'\\'
> +		(	'n'
> +		|	'r'
> +		|	't'
> +		|	'b'
> +		|	'f'
> +		|	'"'
> +		|	'\''
> +		|	'\\'
> +		|	('u')+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
> +		|	'0'..'3'
> +			(
> +				options {
> +					warnWhenFollowAmbig = false;
> +				}
> +			:	'0'..'7'
> +				(
> +					options {
> +						warnWhenFollowAmbig = false;
> +					}
> +				:	'0'..'7'
> +				)?
> +			)?
> +		|	'4'..'7'
> +			(
> +				options {
> +					warnWhenFollowAmbig = false;
> +				}
> +			:	'0'..'7'
> +			)?
> +		)
> +	;
> +
> +
> +// hexadecimal digit (again, note it's protected!)
> +protected
> +HEX_DIGIT
> +	:	('0'..'9'|'A'..'F'|'a'..'f')
> +	;
> +
> +
> +// an identifier.  Note that testLiterals is set to true!  This means
> +// that after we match the rule, we look in the literals table to see
> +// if it's a literal or really an identifer
> +IDENT
> +	options {testLiterals=true;}
> +	:	('a'..'z'|'A'..'Z'|'_'|'$')  
> ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'$'|'/')*
> +	;
> +
> +//DATE_TIME
> + //  : ('0'..'9'|STAR) ('0'..'9'|STAR)('0'..'9'|STAR)('0'..'9'| 
> STAR)('0'..'1'|STAR)('0'..'9'|STAR)('0'..'3'|STAR)('0'..'9'|STAR) 
> ('0'..'6'|STAR)('0'..'9'|STAR)('0'..'6'|STAR)('0'..'9'|STAR) 
> ('0'..'6'|STAR)('0'..'9'|STAR)(DOT)('0'..'9'|STAR)('0'..'9'|STAR) 
> ('0'..'9'|STAR)('0'..'9'|STAR)('0'..'9'|STAR)('0'..'9'|STAR)(PLUS| 
> MINUS)('0'..'9'|STAR)('0'..'9'|STAR)('0'..'9'|STAR){_ttype =  
> DATE_TIME;}
> + //
> +//	 ;
> +// a numeric literal
> +NUM_INT
> +	{boolean isDecimal=false; Token t=null;}
> +    :   '.' {_ttype = DOT;}
> +            (	('0'..'9')+ (EXPONENT)? (f1:FLOAT_SUFFIX {t=f1;})?
> +                {
> +				if (t != null && t.getText().toUpperCase().indexOf('F')>=0) {
> +                	_ttype = NUM_FLOAT;
> +				}
> +				else {
> +                	_ttype = NUM_DOUBLE; // assume double
> +				}
> +				}
> +            )?
> +
> +	|	(	'0' {isDecimal = true;} // special case for just '0'
> +			(	('x'|'X')
> +				(											// hex
> +					// the 'e'|'E' and float suffix stuff look
> +					// like hex digits, hence the (...)+ doesn't
> +					// know when to stop: ambig.  ANTLR resolves
> +					// it correctly by matching immediately.  It
> +					// is therefor ok to hush warning.
> +					options {
> +						warnWhenFollowAmbig=false;
> +					}
> +				:	HEX_DIGIT
> +				)+
> +
> +			|	//float or double with leading zero
> +				(('0'..'9')+ ('.'|EXPONENT|FLOAT_SUFFIX)) => ('0'..'9')+
> +
> +			|	('0'..'7')+									// octal
> +			)?
> +		|	('1'..'9') ('0'..'9')*  {isDecimal=true;}		// non-zero decimal
> +		)
> +		(	('l'|'L') { _ttype = NUM_LONG; }
> +
> +		// only check to see if it's a float if looks like decimal so far
> +		|	{isDecimal}?
> +            (   '.' ('0'..'9')* (EXPONENT)? (f2:FLOAT_SUFFIX  
> {t=f2;})?
> +            |   EXPONENT (f3:FLOAT_SUFFIX {t=f3;})?
> +            |   f4:FLOAT_SUFFIX {t=f4;}
> +            )
> +            {
> +			if (t != null && t.getText().toUpperCase() .indexOf('F') >= 0) {
> +                _ttype = NUM_FLOAT;
> +			}
> +            else {
> +	           	_ttype = NUM_DOUBLE; // assume double
> +			}
> +			}
> +        )?
> +	;
> +
> +
> +// a couple protected methods to assist in matching floating point  
> numbers
> +protected
> +EXPONENT
> +	:	('e'|'E') ('+'|'-')? ('0'..'9')+
> +	;
> +
> +
> +protected
> +FLOAT_SUFFIX
> +	:	'f'|'F'|'d'|'D'
> +	;
> +
> +
>
> Propchange: incubator/imperius/trunk/imperius-splcore/src/main/ 
> antlr/org/apache/imperius/spl/parser/compiler/cimspl.g
> ---------------------------------------------------------------------- 
> --------
>     svn:eol-style = native
>
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message