コード例 #1
0
        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 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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
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 );
 }