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


Java ANTLRParser.ASSIGN属性代码示例

本文整理汇总了Java中org.antlr.v4.parse.ANTLRParser.ASSIGN属性的典型用法代码示例。如果您正苦于以下问题:Java ANTLRParser.ASSIGN属性的具体用法?Java ANTLRParser.ASSIGN怎么用?Java ANTLRParser.ASSIGN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.antlr.v4.parse.ANTLRParser的用法示例。


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

示例1: LabelElementPair

public LabelElementPair(Grammar g, GrammarAST label, GrammarAST element, int labelOp) {
    this.label = label;
    this.element = element;
    // compute general case for label type
    if ( element.getFirstDescendantWithType(tokenTypeForTokens)!=null ) {
        if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.TOKEN_LABEL;
        else type = LabelType.TOKEN_LIST_LABEL;
    }
    else if ( element.getFirstDescendantWithType(ANTLRParser.RULE_REF)!=null ) {
        if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.RULE_LABEL;
        else type = LabelType.RULE_LIST_LABEL;
    }

    // now reset if lexer and string
    if ( g.isLexer() ) {
        if ( element.getFirstDescendantWithType(ANTLRParser.STRING_LITERAL)!=null ) {
            if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.LEXER_STRING_LABEL;
        }
    }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:20,代码来源:LabelElementPair.java

示例2: findOptionValueAST

/** Manually get option node from tree; return null if no defined. */
public static GrammarAST findOptionValueAST(GrammarRootAST root, String option) {
	GrammarAST options = (GrammarAST)root.getFirstChildWithType(ANTLRParser.OPTIONS);
	if ( options!=null && options.getChildCount() > 0 ) {
		for (Object o : options.getChildren()) {
			GrammarAST c = (GrammarAST)o;
			if ( c.getType() == ANTLRParser.ASSIGN &&
				 c.getChild(0).getText().equals(option) )
			{
				return (GrammarAST)c.getChild(1);
			}
		}
	}
	return null;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:15,代码来源:Tool.java

示例3: setNodeOptions

/** Given ^(TOKEN_REF ^(OPTIONS ^(ELEMENT_OPTIONS (= assoc right))))
 *  set option assoc=right in TOKEN_REF.
 */
public static void setNodeOptions(GrammarAST node, GrammarAST options) {
	if ( options==null ) return;
	GrammarASTWithOptions t = (GrammarASTWithOptions)node;
	if ( t.getChildCount()==0 || options.getChildCount()==0 ) return;
	for (Object o : options.getChildren()) {
		GrammarAST c = (GrammarAST)o;
		if ( c.getType()==ANTLRParser.ASSIGN ) {
			t.setOption(c.getChild(0).getText(), (GrammarAST)c.getChild(1));
		}
		else {
			t.setOption(c.getText(), null); // no arg such as ID<VarNodeType>
		}
	}
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:17,代码来源:Grammar.java

示例4: grammarSymbolCausesIssueInGeneratedCode

public boolean grammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode) {
	switch (idNode.getParent().getType()) {
		case ANTLRParser.ASSIGN:
			switch (idNode.getParent().getParent().getType()) {
				case ANTLRParser.ELEMENT_OPTIONS:
				case ANTLRParser.OPTIONS:
					return false;

				default:
					break;
			}

			break;

		case ANTLRParser.AT:
		case ANTLRParser.ELEMENT_OPTIONS:
			return false;

		case ANTLRParser.LEXER_ACTION_CALL:
			if (idNode.getChildIndex() == 0) {
				// first child is the command name which is part of the ANTLR language
				return false;
			}

			// arguments to the command should be checked
			break;

		default:
			break;
	}

	return visibleGrammarSymbolCausesIssueInGeneratedCode(idNode);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:33,代码来源:Target.java

示例5: LeftRecursiveRuleFunction

public LeftRecursiveRuleFunction(OutputModelFactory factory, LeftRecursiveRule r) {
	super(factory, r);

	CodeGenerator gen = factory.getGenerator();
	// Since we delete x=lr, we have to manually add decls for all labels
	// on left-recur refs to proper structs
	for (Pair<GrammarAST,String> pair : r.leftRecursiveRuleRefLabels) {
		GrammarAST idAST = pair.a;
		String altLabel = pair.b;
		String label = idAST.getText();
		GrammarAST rrefAST = (GrammarAST)idAST.getParent().getChild(1);
		if ( rrefAST.getType() == ANTLRParser.RULE_REF ) {
			Rule targetRule = factory.getGrammar().getRule(rrefAST.getText());
			String ctxName = gen.getTarget().getRuleFunctionContextStructName(targetRule);
			RuleContextDecl d;
			if (idAST.getParent().getType() == ANTLRParser.ASSIGN) {
				d = new RuleContextDecl(factory, label, ctxName);
			}
			else {
				d = new RuleContextListDecl(factory, label, ctxName);
			}

			StructDecl struct = ruleCtx;
			if ( altLabelCtxs!=null ) {
				StructDecl s = altLabelCtxs.get(altLabel);
				if ( s!=null ) struct = s; // if alt label, use subctx
			}
			struct.addDecl(d); // stick in overall rule's ctx
		}
	}
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:31,代码来源:LeftRecursiveRuleFunction.java

示例6: getElementOffset

private int getElementOffset(CommonTree tree) {
    switch (tree.getType()) {
    case ANTLRParser.MODE:
    case ANTLRParser.ASSIGN:
    case ANTLRParser.RULE:
        if (tree.getChildCount() > 0 && tree.getChild(0) instanceof CommonTree) {
            CommonTree child = (CommonTree)tree.getChild(0);
            if (child.getToken() instanceof CommonToken) {
                CommonToken token = (CommonToken)child.getToken();
                return token.getStartIndex();
            }
        }

        break;

    case ANTLRParser.ID:
        break;

    default:
        throw new UnsupportedOperationException();
    }

    if (tree.getToken() instanceof CommonToken) {
        return ((CommonToken)tree.getToken()).getStartIndex();
    }

    return 0;
}
 
开发者ID:tunnelvisionlabs,项目名称:goworks,代码行数:28,代码来源:RuleScannerV4.java


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