private void HandleSetElementTokenReference(IIntSet elements, GrammarAST t)
        {
            int ttype;

            if (grammar.type == GrammarType.Lexer)
            {
                // recursively will invoke this rule to match elements in target rule ref
                IIntSet ruleSet = grammar.GetSetFromRule(this, t.Text);
                if (ruleSet == null)
                {
                    ErrorManager.GrammarError(ErrorManager.MSG_RULE_INVALID_SET, grammar, t.Token, t.Text);
                }
                else
                {
                    elements.AddAll(ruleSet);
                }
            }
            else
            {
                ttype = grammar.GetTokenType(t.Text);
                if (elements.Contains(ttype))
                {
                    ErrorManager.GrammarError(ErrorManager.MSG_DUPLICATE_SET_ENTRY, grammar, t.Token, t.Text);
                }

                elements.Add(ttype);
            }
        }
예제 #2
0
 private void HandleSetElementCharRange(IIntSet elements, GrammarAST c1, GrammarAST c2)
 {
     if (grammar.type == GrammarType.Lexer)
     {
         int a = Grammar.GetCharValueFromGrammarCharLiteral(c1.Text);
         int b = Grammar.GetCharValueFromGrammarCharLiteral(c2.Text);
         elements.AddAll(IntervalSet.Of(a, b));
     }
 }
예제 #3
0
        public virtual void Add(Label a)
        {
            if (IsAtom)
            {
                _labelSet = IntervalSet.Of(label);
                label     = SET;
                if (a.IsAtom)
                {
                    _labelSet.Add(a.Atom);
                }
                else if (a.IsSet)
                {
                    _labelSet.AddAll(a.Set);
                }
                else
                {
                    throw new InvalidOperationException("can't add element to Label of type " + label);
                }

                return;
            }

            if (IsSet)
            {
                if (a.IsAtom)
                {
                    _labelSet.Add(a.Atom);
                }
                else if (a.IsSet)
                {
                    _labelSet.AddAll(a.Set);
                }
                else
                {
                    throw new InvalidOperationException("can't add element to Label of type " + label);
                }

                return;
            }

            throw new InvalidOperationException("can't add element to Label of type " + label);
        }
        private void HandleSetElementTokenReference(IIntSet elements, GrammarAST t)
        {
            int ttype;
            if (grammar.type == GrammarType.Lexer)
            {
                // recursively will invoke this rule to match elements in target rule ref
                IIntSet ruleSet = grammar.GetSetFromRule(this, t.Text);
                if (ruleSet == null)
                    ErrorManager.GrammarError(ErrorManager.MSG_RULE_INVALID_SET, grammar, t.Token, t.Text);
                else
                    elements.AddAll(ruleSet);
            }
            else
            {
                ttype = grammar.GetTokenType(t.Text);
                if (elements.Contains(ttype))
                    ErrorManager.GrammarError(ErrorManager.MSG_DUPLICATE_SET_ENTRY, grammar, t.Token, t.Text);

                elements.Add(ttype);
            }
        }
 private void HandleSetElementSet(IIntSet elements, StateCluster g)
 {
     Transition setTrans = g.Left.GetTransition(0);
     elements.AddAll(setTrans.Label.Set);
 }
 private void HandleSetElementNotSetElement(IIntSet elements, IIntSet ns)
 {
     IIntSet not = grammar.Complement(ns);
     elements.AddAll(not);
 }
 private void HandleSetElementCharRange(IIntSet elements, GrammarAST c1, GrammarAST c2)
 {
     if (grammar.type == GrammarType.Lexer)
     {
         int a = Grammar.GetCharValueFromGrammarCharLiteral(c1.Text);
         int b = Grammar.GetCharValueFromGrammarCharLiteral(c2.Text);
         elements.AddAll(IntervalSet.Of(a, b));
     }
 }
예제 #8
0
 private void HandleSetElementNotSetElement(IIntSet elements, IIntSet ns)
 {
     IIntSet not = grammar.Complement(ns);
     elements.AddAll(not);
 }
예제 #9
0
 private void HandleSetElementSet(IIntSet elements, StateCluster g)
 {
     Transition setTrans = g.Left.GetTransition(0);
     elements.AddAll(setTrans.Label.Set);
 }
예제 #10
0
파일: Label.cs 프로젝트: bszafko/antlrcs
 public virtual void Add( Label a )
 {
     if ( IsAtom )
     {
         _labelSet = IntervalSet.Of( label );
         label = SET;
         if ( a.IsAtom )
         {
             _labelSet.Add( a.Atom );
         }
         else if ( a.IsSet )
         {
             _labelSet.AddAll( a.Set );
         }
         else
         {
             throw new InvalidOperationException( "can't add element to Label of type " + label );
         }
         return;
     }
     if ( IsSet )
     {
         if ( a.IsAtom )
         {
             _labelSet.Add( a.Atom );
         }
         else if ( a.IsSet )
         {
             _labelSet.AddAll( a.Set );
         }
         else
         {
             throw new InvalidOperationException( "can't add element to Label of type " + label );
         }
         return;
     }
     throw new InvalidOperationException( "can't add element to Label of type " + label );
 }