Esempio n. 1
0
        /// <summary>
        /// Has this rule already parsed input at the current index in the
        /// input stream?  Return the stop token index or MEMO_RULE_UNKNOWN.
        /// If we attempted but failed to parse properly before, return
        /// MEMO_RULE_FAILED.
        ///
        /// This method has a side-effect: if we have seen this input for
        /// this rule and successfully parsed before, then seek ahead to
        /// 1 past the stop token matched for this rule last time.
        /// </summary>
        public virtual bool AlreadyParsedRule(IIntStream input, int ruleIndex)
        {
            int stopIndex = GetRuleMemoization(ruleIndex, input.Index());

            if (stopIndex == MEMO_RULE_UNKNOWN)
            {
                return(false);
            }
            if (stopIndex == MEMO_RULE_FAILED)
            {
                state.failed = true;
            }
            else
            {
                input.Seek(stopIndex + 1);                 // jump to one past stop token
            }
            return(true);
        }
        public virtual bool AlreadyParsedRule(IIntStream input, int ruleIndex)
        {
            int ruleMemoization = this.GetRuleMemoization(ruleIndex, input.Index);
            switch (ruleMemoization)
            {
                case -1:
                    return false;

                case -2:
                    this.state.failed = true;
                    break;

                default:
                    input.Seek(ruleMemoization + 1);
                    break;
            }
            return true;
        }
Esempio n. 3
0
        public virtual bool AlreadyParsedRule(IIntStream input, int ruleIndex)
        {
            int ruleMemoization = this.GetRuleMemoization(ruleIndex, input.Index);

            switch (ruleMemoization)
            {
            case -1:
                return(false);

            case -2:
                this.state.failed = true;
                break;

            default:
                input.Seek(ruleMemoization + 1);
                break;
            }
            return(true);
        }
        /** <summary>
         *  Has this rule already parsed input at the current index in the
         *  input stream?  Return the stop token index or MEMO_RULE_UNKNOWN.
         *  If we attempted but failed to parse properly before, return
         *  MEMO_RULE_FAILED.
         *  </summary>
         *
         *  <remarks>
         *  This method has a side-effect: if we have seen this input for
         *  this rule and successfully parsed before, then seek ahead to
         *  1 past the stop token matched for this rule last time.
         *  </remarks>
         */
        public virtual bool AlreadyParsedRule(IIntStream input, int ruleIndex)
        {
            int stopIndex = GetRuleMemoization(ruleIndex, input.Index);

            if (stopIndex == MemoRuleUnknown)
            {
                return(false);
            }
            if (stopIndex == MemoRuleFailed)
            {
                //System.out.println("rule "+ruleIndex+" will never succeed");
                state.failed = true;
            }
            else
            {
                //System.out.println("seen rule "+ruleIndex+" before; skipping ahead to @"+(stopIndex+1)+" failed="+state.failed);
                input.Seek(stopIndex + 1);   // jump to one past stop token
            }
            return(true);
        }
Esempio n. 5
0
		/// <summary>
		/// Has this rule already parsed input at the current index in the
		/// input stream?  Return the stop token index or MEMO_RULE_UNKNOWN.
		/// If we attempted but failed to parse properly before, return
		/// MEMO_RULE_FAILED.
		/// 
		/// This method has a side-effect: if we have seen this input for
		/// this rule and successfully parsed before, then seek ahead to
		/// 1 past the stop token matched for this rule last time.
		/// </summary>
		public virtual bool AlreadyParsedRule(IIntStream input, int ruleIndex)
		{
			int stopIndex = GetRuleMemoization(ruleIndex, input.Index);
			if (stopIndex == MEMO_RULE_UNKNOWN)
			{
				return false;
			}
			if (stopIndex == MEMO_RULE_FAILED)
			{
				state.failed = true;
			}
			else
			{
				input.Seek(stopIndex + 1); // jump to one past stop token
			}
			return true;
		}
Esempio n. 6
0
 /** <summary>
  *  Has this rule already parsed input at the current index in the
  *  input stream?  Return the stop token index or MEMO_RULE_UNKNOWN.
  *  If we attempted but failed to parse properly before, return
  *  MEMO_RULE_FAILED.
  *  </summary>
  *
  *  <remarks>
  *  This method has a side-effect: if we have seen this input for
  *  this rule and successfully parsed before, then seek ahead to
  *  1 past the stop token matched for this rule last time.
  *  </remarks>
  */
 public virtual bool AlreadyParsedRule( IIntStream input, int ruleIndex )
 {
     int stopIndex = GetRuleMemoization( ruleIndex, input.Index );
     if ( stopIndex == MemoRuleUnknown )
     {
         return false;
     }
     if ( stopIndex == MemoRuleFailed )
     {
         //System.out.println("rule "+ruleIndex+" will never succeed");
         state.failed = true;
     }
     else
     {
         //System.out.println("seen rule "+ruleIndex+" before; skipping ahead to @"+(stopIndex+1)+" failed="+state.failed);
         input.Seek( stopIndex + 1 ); // jump to one past stop token
     }
     return true;
 }