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);
            }
        }
Exemplo n.º 2
0
        private void HandleSetElementStringLiteral(IIntSet elements, GrammarAST s)
        {
            int ttype = grammar.GetTokenType(s.Text);
            if (elements.Contains(ttype))
                ErrorManager.GrammarError(ErrorManager.MSG_DUPLICATE_SET_ENTRY, grammar, s.Token, s.Text);

            elements.Add(ttype);
        }
Exemplo n.º 3
0
        private void HandleSetElementCharLiteral(IIntSet elements, GrammarAST c)
        {
            int ttype;
            if (grammar.type == GrammarType.Lexer)
                ttype = Grammar.GetCharValueFromGrammarCharLiteral(c.Text);
            else
                ttype = grammar.GetTokenType(c.Text);

            if (elements.Contains(ttype))
                ErrorManager.GrammarError(ErrorManager.MSG_DUPLICATE_SET_ENTRY, grammar, c.Token, c.Text);

            elements.Add(ttype);
        }
Exemplo n.º 4
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 HandleSetElementStringLiteral(IIntSet elements, GrammarAST s)
        {
            int ttype = grammar.GetTokenType(s.Text);
            if (elements.Contains(ttype))
                ErrorManager.GrammarError(ErrorManager.MSG_DUPLICATE_SET_ENTRY, grammar, s.Token, s.Text);

            elements.Add(ttype);
        }
        private void HandleSetElementCharLiteral(IIntSet elements, GrammarAST c)
        {
            int ttype;
            if (grammar.type == GrammarType.Lexer)
                ttype = Grammar.GetCharValueFromGrammarCharLiteral(c.Text);
            else
                ttype = grammar.GetTokenType(c.Text);

            if (elements.Contains(ttype))
                ErrorManager.GrammarError(ErrorManager.MSG_DUPLICATE_SET_ENTRY, grammar, c.Token, c.Text);

            elements.Add(ttype);
        }
Exemplo n.º 8
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 );
 }