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 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));
     }
 }
Beispiel #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));
     }
 }
 private void HandleSetElementNotSetElement(IIntSet elements, IIntSet ns)
 {
     IIntSet not = grammar.Complement(ns);
     elements.AddAll(not);
 }
 private void HandleSetElementSet(IIntSet elements, StateCluster g)
 {
     Transition setTrans = g.Left.GetTransition(0);
     elements.AddAll(setTrans.Label.Set);
 }
Beispiel #10
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 );
 }