// Expected BitSet / not BitSet
 public MismatchedCharException(char c, BitSet set_, bool matchNot, CharScanner scanner_)
     : base("Mismatched char", scanner_.getFilename(), scanner_.getLine(), scanner_.getColumn())
 {
     mismatchType = matchNot ? CharTypeEnum.NotSetType : CharTypeEnum.SetType;
     foundChar = c;
     bset = set_;
     scanner = scanner_;
 }
Example #2
0
 public virtual void andInPlace(BitSet a)
 {
     var min = (int) (Math.Min(dataBits.Length, a.dataBits.Length));
      for (var i = min - 1; i >= 0; i--)
     {
         dataBits[i] &= a.dataBits[i];
     }
     // clear all bits in this not present in a (if this bigger than a).
      for (var i = min; i < dataBits.Length; i++)
     {
         dataBits[i] = 0;
     }
 }
Example #3
0
 public virtual BitSet and(BitSet a)
 {
     var s = (BitSet) this.Clone();
     s.andInPlace(a);
     return s;
 }
 public virtual void hide(BitSet mask)
 {
     hideMask = mask;
 }
 // Expected BitSet / not BitSet
 public MismatchedTokenException(string[] tokenNames_, IToken token_, BitSet set_, bool matchNot, string fileName_)
     : base("Mismatched Token", fileName_, token_.getLine(), token_.getColumn())
 {
     tokenNames = tokenNames_;
     token = token_;
     tokenText = token_.getText();
     mismatchType = matchNot ? TokenTypeEnum.NotSetType : TokenTypeEnum.SetType;
     bset = set_;
 }
Example #6
0
 public virtual void orInPlace(BitSet a)
 {
     // If this is smaller than a, grow this first
     if (a.dataBits.Length > dataBits.Length)
     {
         setSize((int) (a.dataBits.Length));
     }
     var min = (int) (System.Math.Min(dataBits.Length, a.dataBits.Length));
      for (var i = min - 1; i >= 0; i--)
     {
         dataBits[i] |= a.dataBits[i];
     }
 }
Example #7
0
 /*Subtract the elements of 'a' from 'this' in-place.
 * Basically, just turn off all bits of 'this' that are in 'a'.
 */
 public virtual void subtractInPlace(BitSet a)
 {
     if (a == null)
         return ;
     // for all words of 'a', turn off corresponding bits of 'this'
      for (var i = 0; i < dataBits.Length && i < a.dataBits.Length; i++)
     {
         dataBits[i] &= ~ a.dataBits[i];
     }
 }
Example #8
0
 /*Consume chars until one matches the given set */
 public virtual void consumeUntil(BitSet bset)
 {
     while (cached_LA1 != EOF_CHAR && !bset.member(cached_LA1))
     {
         consume();
     }
 }
Example #9
0
 public virtual void match(BitSet b)
 {
     if (!b.member(cached_LA1))
     {
         throw new MismatchedCharException(cached_LA1, b, false, this);
     }
     consume();
 }
Example #10
0
 /*Make sure current lookahead symbol matches the given set
 * Throw an exception upon mismatch, which is catch by either the
 * error handler or by the syntactic predicate.
 */
 public virtual void match(BitSet b)
 {
     if (!b.member(LA(1)))
         throw new MismatchedTokenException(tokenNames, LT(1), b, false, getFilename());
     else
         consume();
 }
 public override void match(BitSet b)
 {
     var text = this.text.ToString();
     var la_1 = LA(1);
     try
     {
         base.match(b);
         eventSupport.fireMatch(la_1, b, text, inputState.guessing);
     }
     catch (MismatchedCharException e)
     {
         if (inputState.guessing == 0)
             eventSupport.fireMismatch(la_1, b, text, inputState.guessing);
         throw e;
     }
 }
Example #12
0
 /*Consume tokens until one matches the given token set */
 public virtual void consumeUntil(BitSet bset)
 {
     while (LA(1) != Token.EOF_TYPE && !bset.member(LA(1)))
     {
         consume();
     }
 }
 // throws MismatchedTokenException, TokenStreamException
 public override void match(BitSet bitSet)
 {
     addCurrentTokenToParseTree();
     base.match(bitSet);
 }
Example #14
0
 /*Make sure current lookahead symbol matches the given set
 * Throw an exception upon mismatch, which is catch by either the
 * error handler or by the syntactic predicate.
 */
 public virtual void match(AST t, BitSet b)
 {
     if (t == null || t == ASTNULL || !b.member(t.Type))
     {
         throw new MismatchedTokenException(getTokenNames(), t, b, false);
     }
 }
Example #15
0
 public virtual object Clone()
 {
     BitSet s;
     try
     {
         s = new BitSet();
         s.dataBits = new long[dataBits.Length];
         Array.Copy(dataBits, 0, s.dataBits, 0, dataBits.Length);
     }
     catch //(System.Exception e)
     {
         throw new System.ApplicationException();
     }
     return s;
 }
Example #16
0
 public virtual void recover(RecognitionException ex, BitSet tokenSet)
 {
     consume();
     consumeUntil(tokenSet);
 }
Example #17
0
 /*return this | a in a new set */
 public virtual BitSet or(BitSet a)
 {
     var s = (BitSet) this.Clone();
     s.orInPlace(a);
     return s;
 }
 public virtual void fireMatch(char c, BitSet b, int guessing)
 {
     var eventDelegate = (MatchEventHandler)((CharScanner)source).Events[Parser.MatchEventKey];
     if (eventDelegate != null)
     {
         matchEvent.setValues(MatchEventArgs.CHAR_BITSET, c, b, null, guessing, false, true);
         eventDelegate(source, matchEvent);
     }
     checkController();
 }
Example #19
0
 /*Is this contained within a? */
 public virtual bool subset(BitSet a)
 {
     if (a == null) //(a == null || !(a is BitSet))
         return false;
     return this.and(a).Equals(this);
 }
 public virtual void fireMismatch(int i, BitSet b, string text, int guessing)
 {
     var eventDelegate = (MatchEventHandler)((CharScanner)source).Events[Parser.MisMatchEventKey];
     if (eventDelegate != null)
     {
         matchEvent.setValues(MatchEventArgs.BITSET, i, b, text, guessing, false, true);
         eventDelegate(source, matchEvent);
     }
     checkController();
 }
Example #21
0
 public static BitSet of(int el)
 {
     var s = new BitSet(el + 1);
     s.add(el);
     return s;
 }
 public TokenStreamBasicFilter(TokenStream input)
 {
     this.input = input;
     discardMask = new BitSet();
 }
 // Expected BitSet / not BitSet
 public MismatchedTokenException(string[] tokenNames_, AST node_, BitSet set_, bool matchNot)
     : base("Mismatched Token", "<AST>", - 1, - 1)
 {
     tokenNames = tokenNames_;
     node = node_;
     if (node_ == null)
     {
         tokenText = "<empty tree>";
     }
     else
     {
         tokenText = node_.ToString();
     }
     mismatchType = matchNot ? TokenTypeEnum.NotSetType : TokenTypeEnum.SetType;
     bset = set_;
 }
 public virtual void discard(BitSet mask)
 {
     discardMask = mask;
 }
 /// <summary>Make sure current lookahead symbol matches the given set
 /// Throw an exception upon mismatch, which is catch by either the
 /// error handler or by the syntactic predicate.
 /// </summary>
 public override void match(BitSet b)
 {
     var text = LT(1).getText();
     var la_1 = LA(1);
     try
     {
         base.match(b);
         parserEventSupport.fireMatch(la_1, b, text, inputState.guessing);
     }
     catch (MismatchedTokenException e)
     {
         if (inputState.guessing == 0)
             parserEventSupport.fireMismatch(la_1, b, text, inputState.guessing);
         throw e;
     }
 }
 public TokenStreamHiddenTokenFilter(TokenStream input)
     : base(input)
 {
     hideMask = new BitSet();
 }