当前位置: 首页>>代码示例>>Java>>正文


Java IntSet类代码示例

本文整理汇总了Java中org.antlr.misc.IntSet的典型用法代码示例。如果您正苦于以下问题:Java IntSet类的具体用法?Java IntSet怎么用?Java IntSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IntSet类属于org.antlr.misc包,在下文中一共展示了IntSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Label

import org.antlr.misc.IntSet; //导入依赖的package包/类
/** Make a set label */
  public Label(IntSet labelSet) {
if ( labelSet==null ) {
	this.label = SET;
	this.labelSet = IntervalSet.of(INVALID);
	return;
}
int singleAtom = labelSet.getSingleElement();
      if ( singleAtom!=INVALID ) {
          // convert back to a single atomic element if |labelSet|==1
          label = singleAtom;
          return;
      }
      this.label = SET;
      this.labelSet = labelSet;
  }
 
开发者ID:Sable,项目名称:mclab-core,代码行数:17,代码来源:Label.java

示例2: build_Set

import org.antlr.misc.IntSet; //导入依赖的package包/类
/** From set build single edge graph o->o-set->o.  To conform to
    *  what an alt block looks like, must have extra state on left.
    */
public StateCluster build_Set(IntSet set) {
       //NFAState start = newState();
       NFAState left = newState();
       //transitionBetweenStates(start, left, Label.EPSILON);
       NFAState right = newState();
       Transition e = new Transition(new Label(set),right);
       left.addTransition(e);
	StateCluster g = new StateCluster(left, right);
       return g;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:14,代码来源:NFAFactory.java

示例3: getCollapsedBlockAsSet

import org.antlr.misc.IntSet; //导入依赖的package包/类
/** Given a collapsed block of alts (a set of atoms), pull out
 *  the set and return it.
 */
protected IntSet getCollapsedBlockAsSet(State blk) {
    State s0 = blk;
    if ( s0!=null && s0.transition(0)!=null ) {
        State s1 = s0.transition(0).target;
        if ( s1!=null && s1.transition(0)!=null ) {
            Label label = s1.transition(0).label;
            if ( label.isSet() ) {
                return label.getSet();
            }
        }
    }
    return null;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:17,代码来源:NFAFactory.java

示例4: getTokenType

import org.antlr.misc.IntSet; //导入依赖的package包/类
protected static Integer getTokenType(Label label) {
	if ( label.isSet() ) {
		// pick random element of set
		IntSet typeSet = label.getSet();
		List typeList = typeSet.toList();
		int randomIndex = random.nextInt(typeList.size());
		return (Integer)typeList.get(randomIndex);
	}
	else {
		return Utils.integer(label.getAtom());
	}
	//System.out.println(t0.label.toString(g));
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:14,代码来源:RandomPhrase.java

示例5: getTokenTypes

import org.antlr.misc.IntSet; //导入依赖的package包/类
/** Return a set of all possible token or char types for this grammar */
public IntSet getTokenTypes() {
	if ( type==LEXER ) {
		return getAllCharValues();
	}
	return IntervalSet.of(Label.MIN_TOKEN_TYPE, getMaxTokenType());
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:8,代码来源:Grammar.java

示例6: getAllCharValues

import org.antlr.misc.IntSet; //导入依赖的package包/类
/** If there is a char vocabulary, use it; else return min to max char
 *  as defined by the target.  If no target, use max unicode char value.
 */
public IntSet getAllCharValues() {
	if ( charVocabulary!=null ) {
		return charVocabulary;
	}
	IntSet allChar = IntervalSet.of(Label.MIN_CHAR_VALUE, getMaxCharValue());
	return allChar;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:11,代码来源:Grammar.java

示例7: complement

import org.antlr.misc.IntSet; //导入依赖的package包/类
/** For lexer grammars, return everything in unicode not in set.
 *  For parser and tree grammars, return everything in token space
 *  from MIN_TOKEN_TYPE to last valid token type or char value.
 */
public IntSet complement(IntSet set) {
    //System.out.println("complement "+set.toString(this));
    //System.out.println("vocabulary "+getTokenTypes().toString(this));
    IntSet c = set.complement(getTokenTypes());
    //System.out.println("result="+c.toString(this));
    return c;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:12,代码来源:Grammar.java

示例8: getSetFromRule

import org.antlr.misc.IntSet; //导入依赖的package包/类
/** Get the set equivalent (if any) of the indicated rule from this
 *  grammar.  Mostly used in the lexer to do ~T for some fragment rule
 *  T.  If the rule AST has a SET use that.  If the rule is a single char
 *  convert it to a set and return.  If rule is not a simple set (w/o actions)
 *  then return null.
 *  Rules have AST form:
 *
 *		^( RULE ID modifier ARG RET SCOPE block EOR )
 */
public IntSet getSetFromRule(TreeToNFAConverter nfabuilder, String ruleName)
	throws RecognitionException
{
	Rule r = getRule(ruleName);
	if ( r==null ) {
		return null;
	}
	IntSet elements = null;
	//System.out.println("parsed tree: "+r.tree.toStringTree());
    elements = nfabuilder.setRule(r.tree);
	//System.out.println("elements="+elements);
	return elements;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:23,代码来源:Grammar.java

示例9: getSet

import org.antlr.misc.IntSet; //导入依赖的package包/类
public IntSet getSet() {
    if ( label!=SET ) {
        // convert single element to a set if they ask for it.
        return IntervalSet.of(label);
    }
    return labelSet;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:8,代码来源:Label.java

示例10: matches

import org.antlr.misc.IntSet; //导入依赖的package包/类
public boolean matches(IntSet set) {
	if ( isAtom() ) {
		return set.member(getAtom());
	}
	if ( isSet() ) {
		// matches if intersection non-nil
		return !getSet().and(set).isNil();
	}
	return false;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:11,代码来源:Label.java

示例11: build_Set

import org.antlr.misc.IntSet; //导入依赖的package包/类
/** From set build single edge graph o->o-set->o.  To conform to
    *  what an alt block looks like, must have extra state on left.
    */
public StateCluster build_Set(IntSet set, GrammarAST associatedAST) {
       NFAState left = newState();
       NFAState right = newState();
	left.associatedASTNode = associatedAST;
	right.associatedASTNode = associatedAST;
	Label label = new Label(set);
	Transition e = new Transition(label,right);
       left.addTransition(e);
	StateCluster g = new StateCluster(left, right);
       return g;
}
 
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:15,代码来源:NFAFactory.java

示例12: getSetValue

import org.antlr.misc.IntSet; //导入依赖的package包/类
public IntSet getSetValue() {
    return setValue;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:4,代码来源:GrammarAST.java

示例13: setSetValue

import org.antlr.misc.IntSet; //导入依赖的package包/类
public void setSetValue(IntSet setValue) {
    this.setValue = setValue;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:4,代码来源:GrammarAST.java

示例14: _LOOK

import org.antlr.misc.IntSet; //导入依赖的package包/类
protected LookaheadSet _LOOK(NFAState s) {
	if ( s.isAcceptState() ) {
		return new LookaheadSet(Label.EOR_TOKEN_TYPE);
	}

	if ( lookBusy.contains(s) ) {
		// return a copy of an empty set; we may modify set inline
		return new LookaheadSet();
	}
	lookBusy.add(s);
	Transition transition0 = s.transition(0);
	if ( transition0==null ) {
		return null;
	}

	if ( transition0.label.isAtom() ) {
		int atom = transition0.label.getAtom();
		if ( atom==Label.EOF ) {
			return LookaheadSet.EOF();
		}
		return new LookaheadSet(atom);
	}
	if ( transition0.label.isSet() ) {
		IntSet sl = transition0.label.getSet();
		LookaheadSet laSet = new LookaheadSet(sl);
		if ( laSet.member(Label.EOF) ) {
			laSet.remove(Label.EOF);
			laSet.hasEOF = true;
		}
		return laSet;
	}
       LookaheadSet tset = _LOOK((NFAState)transition0.target);
	if ( tset.member(Label.EOR_TOKEN_TYPE) ) {
		if ( transition0 instanceof RuleClosureTransition ) {
			// we called a rule that found the end of the rule.
			// That means the rule is nullable and we need to
			// keep looking at what follows the rule ref.  E.g.,
			// a : b A ; where b is nullable means that LOOK(a)
			// should include A.
			RuleClosureTransition ruleInvocationTrans =
				(RuleClosureTransition)transition0;
			// remove the EOR and get what follows
			tset.remove(Label.EOR_TOKEN_TYPE);
			LookaheadSet fset =
				_LOOK((NFAState)ruleInvocationTrans.getFollowState());
			tset.orInPlace(fset);
		}
	}

	Transition transition1 = s.transition(1);
	if ( transition1!=null ) {
		LookaheadSet tset1 = _LOOK((NFAState)transition1.target);
		tset.orInPlace(tset1);
	}
	return tset;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:57,代码来源:Grammar.java

示例15: LookaheadSet

import org.antlr.misc.IntSet; //导入依赖的package包/类
public LookaheadSet(IntSet s) {
	this();
	tokenTypeSet.addAll(s);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:5,代码来源:LookaheadSet.java


注:本文中的org.antlr.misc.IntSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。