/*
* generated by Xtext
*/
grammar InternalItems;

options {
	superClass=AbstractInternalAntlrParser;
	
}

@lexer::header {
package org.openhab.model.parser.antlr.internal;

// Hack: Use our own Lexer superclass by means of import. 
// Currently there is no other way to specify the superclass for the lexer.
import org.eclipse.xtext.parser.antlr.Lexer;
}

@parser::header {
package org.openhab.model.parser.antlr.internal; 

import java.io.InputStream;
import org.eclipse.xtext.*;
import org.eclipse.xtext.parser.*;
import org.eclipse.xtext.parser.impl.*;
import org.eclipse.xtext.parsetree.*;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser;
import org.eclipse.xtext.parser.antlr.XtextTokenStream;
import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens;
import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken;
import org.eclipse.xtext.conversion.ValueConverterException;
import org.openhab.model.services.ItemsGrammarAccess;

}

@parser::members {

 	private ItemsGrammarAccess grammarAccess;
 	
    public InternalItemsParser(TokenStream input, IAstFactory factory, ItemsGrammarAccess grammarAccess) {
        this(input);
        this.factory = factory;
        registerRules(grammarAccess.getGrammar());
        this.grammarAccess = grammarAccess;
    }
    
    @Override
    protected InputStream getTokenFile() {
    	ClassLoader classLoader = getClass().getClassLoader();
    	return classLoader.getResourceAsStream("org/openhab/model/parser/antlr/internal/InternalItems.tokens");
    }
    
    @Override
    protected String getFirstRuleName() {
    	return "ItemModel";	
   	}
   	
   	@Override
   	protected ItemsGrammarAccess getGrammarAccess() {
   		return grammarAccess;
   	}
}

@rulecatch { 
    catch (RecognitionException re) { 
        recover(input,re); 
        appendSkippedTokens();
    } 
}




// Entry rule entryRuleItemModel
entryRuleItemModel returns [EObject current=null] 
	:
	{ currentNode = createCompositeNode(grammarAccess.getItemModelRule(), currentNode); }
	 iv_ruleItemModel=ruleItemModel 
	 { $current=$iv_ruleItemModel.current; } 
	 EOF 
;

// Rule ItemModel
ruleItemModel returns [EObject current=null] 
    @init { EObject temp=null; setCurrentLookahead(); resetLookahead(); 
    }
    @after { resetLookahead(); 
    	lastConsumedNode = currentNode;
    }:
(
(
		{ 
	        currentNode=createCompositeNode(grammarAccess.getItemModelAccess().getItemsModelItemParserRuleCall_0(), currentNode); 
	    }
		lv_items_0_0=ruleModelItem		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getItemModelRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode.getParent(), $current);
	        }
	        try {
	       		add(
	       			$current, 
	       			"items",
	        		lv_items_0_0, 
	        		"ModelItem", 
	        		currentNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	        currentNode = currentNode.getParent();
	    }

)
)*
;





// Entry rule entryRuleModelItem
entryRuleModelItem returns [EObject current=null] 
	:
	{ currentNode = createCompositeNode(grammarAccess.getModelItemRule(), currentNode); }
	 iv_ruleModelItem=ruleModelItem 
	 { $current=$iv_ruleModelItem.current; } 
	 EOF 
;

// Rule ModelItem
ruleModelItem returns [EObject current=null] 
    @init { EObject temp=null; setCurrentLookahead(); resetLookahead(); 
    }
    @after { resetLookahead(); 
    	lastConsumedNode = currentNode;
    }:
((
    { 
        currentNode=createCompositeNode(grammarAccess.getModelItemAccess().getModelNormalItemParserRuleCall_0_0(), currentNode); 
    }
    this_ModelNormalItem_0=ruleModelNormalItem
    { 
        $current = $this_ModelNormalItem_0.current; 
        currentNode = currentNode.getParent();
    }

    |
    { 
        currentNode=createCompositeNode(grammarAccess.getModelItemAccess().getModelGroupItemParserRuleCall_0_1(), currentNode); 
    }
    this_ModelGroupItem_1=ruleModelGroupItem
    { 
        $current = $this_ModelGroupItem_1.current; 
        currentNode = currentNode.getParent();
    }
)(
(
		lv_name_2_0=RULE_ID
		{
			createLeafNode(grammarAccess.getModelItemAccess().getNameIDTerminalRuleCall_1_0(), "name"); 
		}
		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
	        try {
	       		set(
	       			$current, 
	       			"name",
	        		lv_name_2_0, 
	        		"ID", 
	        		lastConsumedNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	    }

)
)(
(
		lv_label_3_0=RULE_STRING
		{
			createLeafNode(grammarAccess.getModelItemAccess().getLabelSTRINGTerminalRuleCall_2_0(), "label"); 
		}
		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
	        try {
	       		set(
	       			$current, 
	       			"label",
	        		lv_label_3_0, 
	        		"STRING", 
	        		lastConsumedNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	    }

)
)?(	'<' 
    {
        createLeafNode(grammarAccess.getModelItemAccess().getLessThanSignKeyword_3_0(), null); 
    }
(
(
(
		lv_icon_5_1=RULE_ID
		{
			createLeafNode(grammarAccess.getModelItemAccess().getIconIDTerminalRuleCall_3_1_0_0(), "icon"); 
		}
		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
	        try {
	       		set(
	       			$current, 
	       			"icon",
	        		lv_icon_5_1, 
	        		"ID", 
	        		lastConsumedNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	    }

    |		lv_icon_5_2=RULE_STRING
		{
			createLeafNode(grammarAccess.getModelItemAccess().getIconSTRINGTerminalRuleCall_3_1_0_1(), "icon"); 
		}
		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
	        try {
	       		set(
	       			$current, 
	       			"icon",
	        		lv_icon_5_2, 
	        		"STRING", 
	        		lastConsumedNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	    }

)

)
)	'>' 
    {
        createLeafNode(grammarAccess.getModelItemAccess().getGreaterThanSignKeyword_3_2(), null); 
    }
)?(	'(' 
    {
        createLeafNode(grammarAccess.getModelItemAccess().getLeftParenthesisKeyword_4_0(), null); 
    }
(
(
		{
			if ($current==null) {
	            $current = factory.create(grammarAccess.getModelItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
        }
	RULE_ID
	{
		createLeafNode(grammarAccess.getModelItemAccess().getGroupsModelGroupItemCrossReference_4_1_0(), "groups"); 
	}

)
)(	',' 
    {
        createLeafNode(grammarAccess.getModelItemAccess().getCommaKeyword_4_2_0(), null); 
    }
(
(
		{
			if ($current==null) {
	            $current = factory.create(grammarAccess.getModelItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
        }
	RULE_ID
	{
		createLeafNode(grammarAccess.getModelItemAccess().getGroupsModelGroupItemCrossReference_4_2_1_0(), "groups"); 
	}

)
))*	')' 
    {
        createLeafNode(grammarAccess.getModelItemAccess().getRightParenthesisKeyword_4_3(), null); 
    }
)?(	'{' 
    {
        createLeafNode(grammarAccess.getModelItemAccess().getLeftCurlyBracketKeyword_5_0(), null); 
    }
(
(
		{ 
	        currentNode=createCompositeNode(grammarAccess.getModelItemAccess().getBindingsModelBindingParserRuleCall_5_1_0(), currentNode); 
	    }
		lv_bindings_13_0=ruleModelBinding		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode.getParent(), $current);
	        }
	        try {
	       		add(
	       			$current, 
	       			"bindings",
	        		lv_bindings_13_0, 
	        		"ModelBinding", 
	        		currentNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	        currentNode = currentNode.getParent();
	    }

)
)(	',' 
    {
        createLeafNode(grammarAccess.getModelItemAccess().getCommaKeyword_5_2_0(), null); 
    }
(
(
		{ 
	        currentNode=createCompositeNode(grammarAccess.getModelItemAccess().getBindingsModelBindingParserRuleCall_5_2_1_0(), currentNode); 
	    }
		lv_bindings_15_0=ruleModelBinding		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode.getParent(), $current);
	        }
	        try {
	       		add(
	       			$current, 
	       			"bindings",
	        		lv_bindings_15_0, 
	        		"ModelBinding", 
	        		currentNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	        currentNode = currentNode.getParent();
	    }

)
))*	'}' 
    {
        createLeafNode(grammarAccess.getModelItemAccess().getRightCurlyBracketKeyword_5_3(), null); 
    }
)*)
;





// Entry rule entryRuleModelGroupItem
entryRuleModelGroupItem returns [EObject current=null] 
	:
	{ currentNode = createCompositeNode(grammarAccess.getModelGroupItemRule(), currentNode); }
	 iv_ruleModelGroupItem=ruleModelGroupItem 
	 { $current=$iv_ruleModelGroupItem.current; } 
	 EOF 
;

// Rule ModelGroupItem
ruleModelGroupItem returns [EObject current=null] 
    @init { EObject temp=null; setCurrentLookahead(); resetLookahead(); 
    }
    @after { resetLookahead(); 
    	lastConsumedNode = currentNode;
    }:
(	'Group' 
    {
        createLeafNode(grammarAccess.getModelGroupItemAccess().getGroupKeyword_0(), null); 
    }
(
    { 
        temp=factory.create(grammarAccess.getModelGroupItemAccess().getModelGroupItemAction_1().getType().getClassifier());
        $current = temp; 
        temp = null;
        CompositeNode newNode = createCompositeNode(grammarAccess.getModelGroupItemAccess().getModelGroupItemAction_1(), currentNode.getParent());
    newNode.getChildren().add(currentNode);
    moveLookaheadInfo(currentNode, newNode);
    currentNode = newNode; 
        associateNodeWithAstElement(currentNode, $current); 
    }
)(	':' 
    {
        createLeafNode(grammarAccess.getModelGroupItemAccess().getColonKeyword_2_0(), null); 
    }
(
(
		{ 
	        currentNode=createCompositeNode(grammarAccess.getModelGroupItemAccess().getTypeModelItemTypeParserRuleCall_2_1_0(), currentNode); 
	    }
		lv_type_3_0=ruleModelItemType		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelGroupItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode.getParent(), $current);
	        }
	        try {
	       		set(
	       			$current, 
	       			"type",
	        		lv_type_3_0, 
	        		"ModelItemType", 
	        		currentNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	        currentNode = currentNode.getParent();
	    }

)
)(	':' 
    {
        createLeafNode(grammarAccess.getModelGroupItemAccess().getColonKeyword_2_2_0(), null); 
    }
(
(
		{ 
	        currentNode=createCompositeNode(grammarAccess.getModelGroupItemAccess().getFunctionModelGroupFunctionEnumRuleCall_2_2_1_0(), currentNode); 
	    }
		lv_function_5_0=ruleModelGroupFunction		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelGroupItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode.getParent(), $current);
	        }
	        try {
	       		set(
	       			$current, 
	       			"function",
	        		lv_function_5_0, 
	        		"ModelGroupFunction", 
	        		currentNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	        currentNode = currentNode.getParent();
	    }

)
)(	'(' 
    {
        createLeafNode(grammarAccess.getModelGroupItemAccess().getLeftParenthesisKeyword_2_2_2_0(), null); 
    }
(
(
(
		lv_args_7_1=RULE_ID
		{
			createLeafNode(grammarAccess.getModelGroupItemAccess().getArgsIDTerminalRuleCall_2_2_2_1_0_0(), "args"); 
		}
		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelGroupItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
	        try {
	       		add(
	       			$current, 
	       			"args",
	        		lv_args_7_1, 
	        		"ID", 
	        		lastConsumedNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	    }

    |		lv_args_7_2=RULE_STRING
		{
			createLeafNode(grammarAccess.getModelGroupItemAccess().getArgsSTRINGTerminalRuleCall_2_2_2_1_0_1(), "args"); 
		}
		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelGroupItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
	        try {
	       		add(
	       			$current, 
	       			"args",
	        		lv_args_7_2, 
	        		"STRING", 
	        		lastConsumedNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	    }

)

)
)(	',' 
    {
        createLeafNode(grammarAccess.getModelGroupItemAccess().getCommaKeyword_2_2_2_2_0(), null); 
    }
(
(
(
		lv_args_9_1=RULE_ID
		{
			createLeafNode(grammarAccess.getModelGroupItemAccess().getArgsIDTerminalRuleCall_2_2_2_2_1_0_0(), "args"); 
		}
		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelGroupItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
	        try {
	       		add(
	       			$current, 
	       			"args",
	        		lv_args_9_1, 
	        		"ID", 
	        		lastConsumedNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	    }

    |		lv_args_9_2=RULE_STRING
		{
			createLeafNode(grammarAccess.getModelGroupItemAccess().getArgsSTRINGTerminalRuleCall_2_2_2_2_1_0_1(), "args"); 
		}
		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelGroupItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
	        try {
	       		add(
	       			$current, 
	       			"args",
	        		lv_args_9_2, 
	        		"STRING", 
	        		lastConsumedNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	    }

)

)
))*	')' 
    {
        createLeafNode(grammarAccess.getModelGroupItemAccess().getRightParenthesisKeyword_2_2_2_3(), null); 
    }
)?)?)?)
;





// Entry rule entryRuleModelNormalItem
entryRuleModelNormalItem returns [EObject current=null] 
	:
	{ currentNode = createCompositeNode(grammarAccess.getModelNormalItemRule(), currentNode); }
	 iv_ruleModelNormalItem=ruleModelNormalItem 
	 { $current=$iv_ruleModelNormalItem.current; } 
	 EOF 
;

// Rule ModelNormalItem
ruleModelNormalItem returns [EObject current=null] 
    @init { EObject temp=null; setCurrentLookahead(); resetLookahead(); 
    }
    @after { resetLookahead(); 
    	lastConsumedNode = currentNode;
    }:
(
(
		{ 
	        currentNode=createCompositeNode(grammarAccess.getModelNormalItemAccess().getTypeModelItemTypeParserRuleCall_0(), currentNode); 
	    }
		lv_type_0_0=ruleModelItemType		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelNormalItemRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode.getParent(), $current);
	        }
	        try {
	       		set(
	       			$current, 
	       			"type",
	        		lv_type_0_0, 
	        		"ModelItemType", 
	        		currentNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	        currentNode = currentNode.getParent();
	    }

)
)
;





// Entry rule entryRuleModelItemType
entryRuleModelItemType returns [String current=null] 
	:
	{ currentNode = createCompositeNode(grammarAccess.getModelItemTypeRule(), currentNode); } 
	 iv_ruleModelItemType=ruleModelItemType 
	 { $current=$iv_ruleModelItemType.current.getText(); }  
	 EOF 
;

// Rule ModelItemType
ruleModelItemType returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] 
    @init { setCurrentLookahead(); resetLookahead(); 
    }
    @after { resetLookahead(); 
	    lastConsumedNode = currentNode;
    }:
(
	kw='Switch' 
    {
        $current.merge(kw);
        createLeafNode(grammarAccess.getModelItemTypeAccess().getSwitchKeyword_0(), null); 
    }

    |
	kw='Rollershutter' 
    {
        $current.merge(kw);
        createLeafNode(grammarAccess.getModelItemTypeAccess().getRollershutterKeyword_1(), null); 
    }

    |
	kw='Number' 
    {
        $current.merge(kw);
        createLeafNode(grammarAccess.getModelItemTypeAccess().getNumberKeyword_2(), null); 
    }

    |
	kw='String' 
    {
        $current.merge(kw);
        createLeafNode(grammarAccess.getModelItemTypeAccess().getStringKeyword_3(), null); 
    }

    |
	kw='Dimmer' 
    {
        $current.merge(kw);
        createLeafNode(grammarAccess.getModelItemTypeAccess().getDimmerKeyword_4(), null); 
    }

    |
	kw='Contact' 
    {
        $current.merge(kw);
        createLeafNode(grammarAccess.getModelItemTypeAccess().getContactKeyword_5(), null); 
    }

    |    this_ID_6=RULE_ID    {
		$current.merge(this_ID_6);
    }

    { 
    createLeafNode(grammarAccess.getModelItemTypeAccess().getIDTerminalRuleCall_6(), null); 
    }
)
    ;





// Entry rule entryRuleModelBinding
entryRuleModelBinding returns [EObject current=null] 
	:
	{ currentNode = createCompositeNode(grammarAccess.getModelBindingRule(), currentNode); }
	 iv_ruleModelBinding=ruleModelBinding 
	 { $current=$iv_ruleModelBinding.current; } 
	 EOF 
;

// Rule ModelBinding
ruleModelBinding returns [EObject current=null] 
    @init { EObject temp=null; setCurrentLookahead(); resetLookahead(); 
    }
    @after { resetLookahead(); 
    	lastConsumedNode = currentNode;
    }:
((
(
		lv_type_0_0=RULE_ID
		{
			createLeafNode(grammarAccess.getModelBindingAccess().getTypeIDTerminalRuleCall_0_0(), "type"); 
		}
		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelBindingRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
	        try {
	       		set(
	       			$current, 
	       			"type",
	        		lv_type_0_0, 
	        		"ID", 
	        		lastConsumedNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	    }

)
)	'=' 
    {
        createLeafNode(grammarAccess.getModelBindingAccess().getEqualsSignKeyword_1(), null); 
    }
(
(
		lv_configuration_2_0=RULE_STRING
		{
			createLeafNode(grammarAccess.getModelBindingAccess().getConfigurationSTRINGTerminalRuleCall_2_0(), "configuration"); 
		}
		{
	        if ($current==null) {
	            $current = factory.create(grammarAccess.getModelBindingRule().getType().getClassifier());
	            associateNodeWithAstElement(currentNode, $current);
	        }
	        try {
	       		set(
	       			$current, 
	       			"configuration",
	        		lv_configuration_2_0, 
	        		"STRING", 
	        		lastConsumedNode);
	        } catch (ValueConverterException vce) {
				handleValueConverterException(vce);
	        }
	    }

)
))
;





// Rule ModelGroupFunction
ruleModelGroupFunction returns [Enumerator current=null] 
    @init { setCurrentLookahead(); resetLookahead(); }
    @after { resetLookahead(); 
    	lastConsumedNode = currentNode;
    }:
((	'AND' 
	{
        $current = grammarAccess.getModelGroupFunctionAccess().getANDEnumLiteralDeclaration_0().getEnumLiteral().getInstance();
        createLeafNode(grammarAccess.getModelGroupFunctionAccess().getANDEnumLiteralDeclaration_0(), null); 
    }
)
    |(	'OR' 
	{
        $current = grammarAccess.getModelGroupFunctionAccess().getOREnumLiteralDeclaration_1().getEnumLiteral().getInstance();
        createLeafNode(grammarAccess.getModelGroupFunctionAccess().getOREnumLiteralDeclaration_1(), null); 
    }
)
    |(	'AVG' 
	{
        $current = grammarAccess.getModelGroupFunctionAccess().getAVGEnumLiteralDeclaration_2().getEnumLiteral().getInstance();
        createLeafNode(grammarAccess.getModelGroupFunctionAccess().getAVGEnumLiteralDeclaration_2(), null); 
    }
)
    |(	'MAX' 
	{
        $current = grammarAccess.getModelGroupFunctionAccess().getMAXEnumLiteralDeclaration_3().getEnumLiteral().getInstance();
        createLeafNode(grammarAccess.getModelGroupFunctionAccess().getMAXEnumLiteralDeclaration_3(), null); 
    }
)
    |(	'MIN' 
	{
        $current = grammarAccess.getModelGroupFunctionAccess().getMINEnumLiteralDeclaration_4().getEnumLiteral().getInstance();
        createLeafNode(grammarAccess.getModelGroupFunctionAccess().getMINEnumLiteralDeclaration_4(), null); 
    }
));



RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;

RULE_INT : ('0'..'9')+;

RULE_STRING : ('"' ('\\' ('b'|'t'|'n'|'f'|'r'|'"'|'\''|'\\')|~(('\\'|'"')))* '"'|'\'' ('\\' ('b'|'t'|'n'|'f'|'r'|'"'|'\''|'\\')|~(('\\'|'\'')))* '\'');

RULE_ML_COMMENT : '/*' ( options {greedy=false;} : . )*'*/';

RULE_SL_COMMENT : '//' ~(('\n'|'\r'))* ('\r'? '\n')?;

RULE_WS : (' '|'\t'|'\r'|'\n')+;

RULE_ANY_OTHER : .;


