Example #1
0
        public virtual void DefineLabel( IToken label, GrammarAST elementRef, LabelType type )
        {
            Grammar.LabelElementPair pair = new Grammar.LabelElementPair( grammar, label, elementRef );
            pair.type = type;
            labelNameSpace[label.Text] = pair;
            switch ( type )
            {
            case LabelType.Token:
                if ( tokenLabels == null )
                {
                    tokenLabels = new Dictionary<string, Grammar.LabelElementPair>();
                }
                tokenLabels[label.Text] = pair;
                break;

            case LabelType.WildcardTree:
                if ( wildcardTreeLabels == null )
                    wildcardTreeLabels = new Dictionary<string, Grammar.LabelElementPair>();
                wildcardTreeLabels[label.Text] = pair;
                break;

            case LabelType.WildcardTreeList:
                if ( wildcardTreeListLabels == null )
                    wildcardTreeListLabels = new Dictionary<string, Grammar.LabelElementPair>();
                wildcardTreeListLabels[label.Text] = pair;
                break;

            case LabelType.Rule:
                if ( ruleLabels == null )
                {
                    ruleLabels = new Dictionary<string, Grammar.LabelElementPair>();
                }
                ruleLabels[label.Text] = pair;
                break;
            case LabelType.TokenList:
                if ( tokenListLabels == null )
                {
                    tokenListLabels = new Dictionary<string, Grammar.LabelElementPair>();
                }
                tokenListLabels[label.Text] = pair;
                break;
            case LabelType.RuleList:
                if ( ruleListLabels == null )
                {
                    ruleListLabels = new Dictionary<string, Grammar.LabelElementPair>();
                }
                ruleListLabels[label.Text] = pair;
                break;
            case LabelType.Char:
                if ( charLabels == null )
                {
                    charLabels = new Dictionary<string, Grammar.LabelElementPair>();
                }
                charLabels[label.Text] = pair;
                break;
            }
        }
Example #2
0
        public virtual void DefineLabel( IToken label, GrammarAST elementRef, LabelType type )
        {
            Grammar.LabelElementPair pair = new Grammar.LabelElementPair( Grammar, label, elementRef );
            pair.type = type;
            LabelNameSpace[label.Text] = pair;
            switch (type)
            {
            case LabelType.Token:
                TokenLabels = TokenLabels ?? new Dictionary<string, Grammar.LabelElementPair>();
                TokenLabels[label.Text] = pair;
                break;

            case LabelType.WildcardTree:
                WildcardTreeLabels = WildcardTreeLabels ?? new Dictionary<string, Grammar.LabelElementPair>();
                WildcardTreeLabels[label.Text] = pair;
                break;

            case LabelType.WildcardTreeList:
                WildcardTreeListLabels = WildcardTreeListLabels ?? new Dictionary<string, Grammar.LabelElementPair>();
                WildcardTreeListLabels[label.Text] = pair;
                break;

            case LabelType.Rule:
                _ruleLabels = _ruleLabels ?? new Dictionary<string, Grammar.LabelElementPair>();
                _ruleLabels[label.Text] = pair;
                break;

            case LabelType.TokenList:
                TokenListLabels = TokenListLabels ?? new Dictionary<string, Grammar.LabelElementPair>();
                TokenListLabels[label.Text] = pair;
                break;

            case LabelType.RuleList:
                _ruleListLabels = _ruleListLabels ?? new Dictionary<string, Grammar.LabelElementPair>();
                _ruleListLabels[label.Text] = pair;
                break;

            case LabelType.Char:
                CharLabels = CharLabels ?? new Dictionary<string, Grammar.LabelElementPair>();
                CharLabels[label.Text] = pair;
                break;

            case LabelType.CharList:
                CharListLabels = CharListLabels ?? new Dictionary<string, Grammar.LabelElementPair>();
                CharListLabels[label.Text] = pair;
                break;

            default:
                throw new ArgumentException(string.Format("Unexpected label type {0}.", type), "type");
            }
        }