Java Code Examples for antlr.collections.AST#getType()

The following examples show how to use antlr.collections.AST#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleCaseNode.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setExpectedType(Type expectedType) {
	AST option = getFirstChild();
	while ( option != null ) {
		if ( option.getType() == HqlSqlTokenTypes.WHEN ) {
			if ( ParameterNode.class.isAssignableFrom( option.getFirstChild().getNextSibling().getClass() ) ) {
				((ParameterNode) option.getFirstChild().getNextSibling()).setExpectedType( expectedType );
			}
		}
		else if ( option.getType() == HqlSqlTokenTypes.ELSE ) {
			if ( ParameterNode.class.isAssignableFrom( option.getFirstChild().getClass() ) ) {
				((ParameterNode) option.getFirstChild()).setExpectedType( expectedType );
			}
		}
		option = option.getNextSibling();
	}
}
 
Example 2
Source File: Qualifier.java    From testability-explorer with Apache License 2.0 6 votes vote down vote up
private void searchAST(AST ast, String prefix) {
  while(ast != null) {
    if (ast.getType() == JavaTokenTypes.PACKAGE_DEF) {
      setPackage(ast.getFirstChild());
    } else if (ast.getType() == JavaTokenTypes.IMPORT) {
      addImport(stringify(ast.getFirstChild()));
    } else if (ast.getType() == JavaTokenTypes.STATIC_IMPORT) {
      //System.out.println(ast.toStringList());
    } else if (ast.getType() == JavaTokenTypes.CLASS_DEF) {
      aliasType(ast.getFirstChild(), prefix);
    } else {
      searchAST(ast.getFirstChild(), prefix);
    }
    ast = ast.getNextSibling();
  }
}
 
Example 3
Source File: TypesUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
/** Returns node corresponding to the name of the CORBA primitive type node.
 *
 * @param node
 * @return
 */
public static AST getCorbaTypeNameNode(AST node) {
    AST currentNode = node;
    if (currentNode.getType() == IDLTokenTypes.LITERAL_unsigned) {
        currentNode = currentNode.getNextSibling();
    }
    if (currentNode.getType() == IDLTokenTypes.LITERAL_long
        && (currentNode.getNextSibling() != null)
        && (currentNode.getNextSibling().getType() == IDLTokenTypes.LITERAL_long)) {
        currentNode = currentNode.getNextSibling();
    }
    return currentNode.getNextSibling();
}
 
Example 4
Source File: SelectClause.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected AST getFirstSelectExpression() {
	AST n = getFirstChild();
	// Skip 'DISTINCT' and 'ALL', so we return the first expression node.
	while ( n != null && ( n.getType() == SqlTokenTypes.DISTINCT || n.getType() == SqlTokenTypes.ALL ) ) {
		n = n.getNextSibling();
	}
	return n;
}
 
Example 5
Source File: ANTLRTreePrinter.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final void ast_suffix(AST _t) throws RecognitionException {
	
	GrammarAST ast_suffix_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t;
	
	try {      // for error handling
		if (_t==null) _t=ASTNULL;
		switch ( _t.getType()) {
		case ROOT:
		{
			GrammarAST tmp80_AST_in = (GrammarAST)_t;
			match(_t,ROOT);
			_t = _t.getNextSibling();
			out("^");
			break;
		}
		case BANG:
		{
			GrammarAST tmp81_AST_in = (GrammarAST)_t;
			match(_t,BANG);
			_t = _t.getNextSibling();
			out("!");
			break;
		}
		default:
		{
			throw new NoViableAltException(_t);
		}
		}
	}
	catch (RecognitionException ex) {
		reportError(ex);
		if (_t!=null) {_t = _t.getNextSibling();}
	}
	_retTree = _t;
}
 
Example 6
Source File: LiteralProcessor.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void processNumeric(AST literal) {
	if ( literal.getType() == NUM_INT || literal.getType() == NUM_LONG ) {
		literal.setText( determineIntegerRepresentation( literal.getText(), literal.getType() ) );
	}
	else if ( literal.getType() == NUM_FLOAT || literal.getType() == NUM_DOUBLE ) {
		literal.setText( determineDecimalRepresentation( literal.getText(), literal.getType() ) );
	}
	else {
		log.warn( "Unexpected literal token type [" + literal.getType() + "] passed for numeric processing" );
	}
}
 
Example 7
Source File: TreeToNFAConverter.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final void rewrite(AST _t) throws RecognitionException {
	
	GrammarAST rewrite_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t;
	
	try {      // for error handling
		{
		_loop64:
		do {
			if (_t==null) _t=ASTNULL;
			if ((_t.getType()==REWRITE)) {
				
							if ( grammar.getOption("output")==null ) {
								ErrorManager.grammarError(ErrorManager.MSG_REWRITE_OR_OP_WITH_NO_OUTPUT_OPTION,
														  grammar, rewrite_AST_in.token, currentRuleName);
							}
							
				AST __t61 = _t;
				GrammarAST tmp39_AST_in = (GrammarAST)_t;
				match(_t,REWRITE);
				_t = _t.getFirstChild();
				{
				if (_t==null) _t=ASTNULL;
				switch ( _t.getType()) {
				case SEMPRED:
				{
					GrammarAST tmp40_AST_in = (GrammarAST)_t;
					match(_t,SEMPRED);
					_t = _t.getNextSibling();
					break;
				}
				case ALT:
				case TEMPLATE:
				case ACTION:
				case ETC:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(_t);
				}
				}
				}
				{
				if (_t==null) _t=ASTNULL;
				switch ( _t.getType()) {
				case ALT:
				{
					GrammarAST tmp41_AST_in = (GrammarAST)_t;
					match(_t,ALT);
					_t = _t.getNextSibling();
					break;
				}
				case TEMPLATE:
				{
					GrammarAST tmp42_AST_in = (GrammarAST)_t;
					match(_t,TEMPLATE);
					_t = _t.getNextSibling();
					break;
				}
				case ACTION:
				{
					GrammarAST tmp43_AST_in = (GrammarAST)_t;
					match(_t,ACTION);
					_t = _t.getNextSibling();
					break;
				}
				case ETC:
				{
					GrammarAST tmp44_AST_in = (GrammarAST)_t;
					match(_t,ETC);
					_t = _t.getNextSibling();
					break;
				}
				default:
				{
					throw new NoViableAltException(_t);
				}
				}
				}
				_t = __t61;
				_t = _t.getNextSibling();
			}
			else {
				break _loop64;
			}
			
		} while (true);
		}
	}
	catch (RecognitionException ex) {
		reportError(ex);
		if (_t!=null) {_t = _t.getNextSibling();}
	}
	_retTree = _t;
}
 
Example 8
Source File: ScopedNameVisitor.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected static boolean isFullyScopedName(AST node) {
    return node.getType() == IDLTokenTypes.IDENT
        && node.getFirstChild() != null
        && ((node.getFirstChild().getType() == IDLTokenTypes.SCOPEOP)
            || (node.getFirstChild().getType() == IDLTokenTypes.IDENT));
}
 
Example 9
Source File: ANTLRTreePrinter.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final void exceptionGroup(AST _t) throws RecognitionException {
	
	GrammarAST exceptionGroup_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t;
	
	try {      // for error handling
		if (_t==null) _t=ASTNULL;
		switch ( _t.getType()) {
		case LITERAL_catch:
		{
			{
			int _cnt85=0;
			_loop85:
			do {
				if (_t==null) _t=ASTNULL;
				if ((_t.getType()==LITERAL_catch)) {
					exceptionHandler(_t);
					_t = _retTree;
				}
				else {
					if ( _cnt85>=1 ) { break _loop85; } else {throw new NoViableAltException(_t);}
				}
				
				_cnt85++;
			} while (true);
			}
			{
			if (_t==null) _t=ASTNULL;
			switch ( _t.getType()) {
			case LITERAL_finally:
			{
				finallyClause(_t);
				_t = _retTree;
				break;
			}
			case EOR:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(_t);
			}
			}
			}
			break;
		}
		case LITERAL_finally:
		{
			finallyClause(_t);
			_t = _retTree;
			break;
		}
		default:
		{
			throw new NoViableAltException(_t);
		}
		}
	}
	catch (RecognitionException ex) {
		reportError(ex);
		if (_t!=null) {_t = _t.getNextSibling();}
	}
	_retTree = _t;
}
 
Example 10
Source File: CodeGenTreeWalker.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final StringTemplate  rewrite_tree(AST _t) throws RecognitionException {
	StringTemplate code=templates.getInstanceOf("rewriteTree");
	
	GrammarAST rewrite_tree_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t;
	
	rewriteTreeNestingLevel++;
	code.setAttribute("treeLevel", rewriteTreeNestingLevel);
	code.setAttribute("enclosingTreeLevel", rewriteTreeNestingLevel-1);
	StringTemplate r, el;
	GrammarAST elAST=null;
	
	
	try {      // for error handling
		AST __t112 = _t;
		GrammarAST tmp76_AST_in = (GrammarAST)_t;
		match(_t,TREE_BEGIN);
		_t = _t.getFirstChild();
		elAST=(GrammarAST)_t;
		r=rewrite_atom(_t,true);
		_t = _retTree;
		code.setAttribute("root.{el,line,pos}",
									   r,
									   Utils.integer(elAST.getLine()),
									   Utils.integer(elAST.getColumn())
									  );
					
		{
		_loop114:
		do {
			if (_t==null) _t=ASTNULL;
			if ((_t.getType()==OPTIONAL||_t.getType()==CLOSURE||_t.getType()==POSITIVE_CLOSURE||_t.getType()==LABEL||_t.getType()==ACTION||_t.getType()==STRING_LITERAL||_t.getType()==CHAR_LITERAL||_t.getType()==TOKEN_REF||_t.getType()==RULE_REF||_t.getType()==TREE_BEGIN)) {
				elAST=(GrammarAST)_t;
				el=rewrite_element(_t);
				_t = _retTree;
				
							  code.setAttribute("children.{el,line,pos}",
											    el,
											    Utils.integer(elAST.getLine()),
											    Utils.integer(elAST.getColumn())
											    );
							
			}
			else {
				break _loop114;
			}
			
		} while (true);
		}
		_t = __t112;
		_t = _t.getNextSibling();
		
				String description = grammar.grammarTreeToString(rewrite_tree_AST_in, false);
				description = generator.target.getTargetStringLiteralFromString(description);
				code.setAttribute("description", description);
			rewriteTreeNestingLevel--;
				
	}
	catch (RecognitionException ex) {
		reportError(ex);
		if (_t!=null) {_t = _t.getNextSibling();}
	}
	_retTree = _t;
	return code;
}
 
Example 11
Source File: DefineGrammarItemsWalker.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final void rewrite(AST _t) throws RecognitionException {
	
	GrammarAST rewrite_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t;
	GrammarAST pred = null;
	
	currentRewriteRule = rewrite_AST_in; // has to execute during guessing
	if ( grammar.buildAST() ) {
	rewrite_AST_in.rewriteRefsDeep = new HashSet<GrammarAST>();
	}
	
	
	try {      // for error handling
		{
		_loop131:
		do {
			if (_t==null) _t=ASTNULL;
			if ((_t.getType()==REWRITE)) {
				AST __t129 = _t;
				GrammarAST tmp39_AST_in = (GrammarAST)_t;
				match(_t,REWRITE);
				_t = _t.getFirstChild();
				{
				if (_t==null) _t=ASTNULL;
				switch ( _t.getType()) {
				case SEMPRED:
				{
					pred = (GrammarAST)_t;
					match(_t,SEMPRED);
					_t = _t.getNextSibling();
					break;
				}
				case ALT:
				case TEMPLATE:
				case ACTION:
				case ETC:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(_t);
				}
				}
				}
				rewrite_alternative(_t);
				_t = _retTree;
				_t = __t129;
				_t = _t.getNextSibling();
				if ( inputState.guessing==0 ) {
					
					if ( pred!=null ) {
					pred.outerAltNum = this.outerAltNum;
					trackInlineAction(pred);
					}
					
				}
			}
			else {
				break _loop131;
			}
			
		} while (true);
		}
	}
	catch (RecognitionException ex) {
		if (inputState.guessing==0) {
			reportError(ex);
			if (_t!=null) {_t = _t.getNextSibling();}
		} else {
		  throw ex;
		}
	}
	_retTree = _t;
}
 
Example 12
Source File: CodeGenTreeWalker.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final StringTemplate  ebnf(AST _t) throws RecognitionException {
	StringTemplate code=null;
	
	GrammarAST ebnf_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t;
	
	DFA dfa=null;
	GrammarAST b = (GrammarAST)ebnf_AST_in.getFirstChild();
	GrammarAST eob = (GrammarAST)b.getLastChild(); // loops will use EOB DFA
	
	
	try {      // for error handling
		{
		if (_t==null) _t=ASTNULL;
		switch ( _t.getType()) {
		case BLOCK:
		{
			dfa = ebnf_AST_in.getLookaheadDFA();
			code=block(_t,"block", dfa);
			_t = _retTree;
			break;
		}
		case OPTIONAL:
		{
			dfa = ebnf_AST_in.getLookaheadDFA();
			AST __t75 = _t;
			GrammarAST tmp49_AST_in = (GrammarAST)_t;
			match(_t,OPTIONAL);
			_t = _t.getFirstChild();
			code=block(_t,"optionalBlock", dfa);
			_t = _retTree;
			_t = __t75;
			_t = _t.getNextSibling();
			break;
		}
		case CLOSURE:
		{
			dfa = eob.getLookaheadDFA();
			AST __t76 = _t;
			GrammarAST tmp50_AST_in = (GrammarAST)_t;
			match(_t,CLOSURE);
			_t = _t.getFirstChild();
			code=block(_t,"closureBlock", dfa);
			_t = _retTree;
			_t = __t76;
			_t = _t.getNextSibling();
			break;
		}
		case POSITIVE_CLOSURE:
		{
			dfa = eob.getLookaheadDFA();
			AST __t77 = _t;
			GrammarAST tmp51_AST_in = (GrammarAST)_t;
			match(_t,POSITIVE_CLOSURE);
			_t = _t.getFirstChild();
			code=block(_t,"positiveClosureBlock", dfa);
			_t = _retTree;
			_t = __t77;
			_t = _t.getNextSibling();
			break;
		}
		default:
		{
			throw new NoViableAltException(_t);
		}
		}
		}
		
				String description = grammar.grammarTreeToString(ebnf_AST_in, false);
				description = generator.target.getTargetStringLiteralFromString(description);
			code.setAttribute("description", description);
			
	}
	catch (RecognitionException ex) {
		reportError(ex);
		if (_t!=null) {_t = _t.getNextSibling();}
	}
	_retTree = _t;
	return code;
}
 
Example 13
Source File: AssignTokenTypesWalker.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final void ebnf(AST _t) throws RecognitionException {
	
	GrammarAST ebnf_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t;
	
	try {      // for error handling
		if (_t==null) _t=ASTNULL;
		switch ( _t.getType()) {
		case BLOCK:
		{
			block(_t);
			_t = _retTree;
			break;
		}
		case OPTIONAL:
		{
			AST __t96 = _t;
			GrammarAST tmp70_AST_in = (GrammarAST)_t;
			match(_t,OPTIONAL);
			_t = _t.getFirstChild();
			block(_t);
			_t = _retTree;
			_t = __t96;
			_t = _t.getNextSibling();
			break;
		}
		case CLOSURE:
		{
			AST __t97 = _t;
			GrammarAST tmp71_AST_in = (GrammarAST)_t;
			match(_t,CLOSURE);
			_t = _t.getFirstChild();
			block(_t);
			_t = _retTree;
			_t = __t97;
			_t = _t.getNextSibling();
			break;
		}
		case POSITIVE_CLOSURE:
		{
			AST __t98 = _t;
			GrammarAST tmp72_AST_in = (GrammarAST)_t;
			match(_t,POSITIVE_CLOSURE);
			_t = _t.getFirstChild();
			block(_t);
			_t = _retTree;
			_t = __t98;
			_t = _t.getNextSibling();
			break;
		}
		default:
		{
			throw new NoViableAltException(_t);
		}
		}
	}
	catch (RecognitionException ex) {
		reportError(ex);
		if (_t!=null) {_t = _t.getNextSibling();}
	}
	_retTree = _t;
}
 
Example 14
Source File: StringVisitor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static boolean accept(AST node) {
    return (node.getType() == IDLTokenTypes.LITERAL_string)
        || (node.getType() == IDLTokenTypes.LITERAL_wstring);
}
 
Example 15
Source File: ProEval.java    From proparse with Eclipse Public License 2.0 4 votes vote down vote up
public final Object  substitute_fun(AST _t) throws RecognitionException {
	Object ret;
	
	AST substitute_fun_AST_in = (_t == ASTNULL) ? null : (AST)_t;
	
		Object a;
		Object b;
	
	
	AST __t133 = _t;
	AST tmp162_AST_in = (AST)_t;
	match(_t,SUBSTITUTE);
	_t = _t.getFirstChild();
	AST tmp163_AST_in = (AST)_t;
	match(_t,LEFTPAREN);
	_t = _t.getNextSibling();
	a=expr(_t);
	_t = _retTree;
	{
	_loop135:
	do {
		if (_t==null) _t=ASTNULL;
		if ((_t.getType()==COMMA)) {
			AST tmp164_AST_in = (AST)_t;
			match(_t,COMMA);
			_t = _t.getNextSibling();
			b=expr(_t);
			_t = _retTree;
		}
		else {
			break _loop135;
		}
		
	} while (true);
	}
	AST tmp165_AST_in = (AST)_t;
	match(_t,RIGHTPAREN);
	_t = _t.getNextSibling();
	_t = __t133;
	_t = _t.getNextSibling();
	if(true) throw new ProEvalException("SUBSTITUTE function not yet supported.");
	_retTree = _t;
	return ret;
}
 
Example 16
Source File: AssignmentSpecification.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public AssignmentSpecification(AST eq, Queryable persister) {
	if ( eq.getType() != HqlSqlTokenTypes.EQ ) {
		throw new QueryException( "assignment in set-clause not associated with equals" );
	}

	this.eq = eq;
	this.factory = persister.getFactory();

	// Needed to bump this up to DotNode, because that is the only thing which currently
	// knows about the property-ref path in the correct format; it is either this, or
	// recurse over the DotNodes constructing the property path just like DotNode does
	// internally
	final DotNode lhs = (DotNode) eq.getFirstChild();
	final SqlNode rhs = (SqlNode) lhs.getNextSibling();

	validateLhs( lhs );

	final String propertyPath = lhs.getPropertyPath();
	Set<String> temp = new HashSet<String>();
	// yuck!
	if ( persister instanceof UnionSubclassEntityPersister ) {
		final String[] tables = persister.getConstraintOrderedTableNameClosure();
		Collections.addAll( temp, tables );
	}
	else {
		temp.add(
				persister.getSubclassTableName( persister.getSubclassPropertyTableNumber( propertyPath ) )
		);
	}
	this.tableNames = Collections.unmodifiableSet( temp );

	if ( rhs == null ) {
		hqlParameters = new ParameterSpecification[0];
	}
	else if ( isParam( rhs ) ) {
		hqlParameters = new ParameterSpecification[] {( (ParameterNode) rhs ).getHqlParameterSpecification()};
	}
	else {
		List parameterList = ASTUtil.collectChildren(
				rhs,
				new ASTUtil.IncludePredicate() {
					public boolean include(AST node) {
						return isParam( node );
					}
				}
		);
		hqlParameters = new ParameterSpecification[parameterList.size()];
		Iterator itr = parameterList.iterator();
		int i = 0;
		while ( itr.hasNext() ) {
			hqlParameters[i++] = ( (ParameterNode) itr.next() ).getHqlParameterSpecification();
		}
	}
}
 
Example 17
Source File: PrimitiveTypesVisitor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static QName getPrimitiveType(AST node) {
    QName result = null;
    switch (node.getType()) {
    case IDLTokenTypes.LITERAL_long:
        if ((node.getNextSibling() != null)
            && (node.getNextSibling().getType() == IDLTokenTypes.LITERAL_long)) {
            // long long
            result = CorbaConstants.NT_CORBA_LONGLONG;
        } else if ((node.getFirstChild() != null)
            && (node.getFirstChild().getType() == IDLTokenTypes.LITERAL_double)) {
            // "double" node is a child of "long" node - instead of being a sibling
            // long double
            result = CorbaConstants.NT_CORBA_LONGDOUBLE;
        } else {
            // long
            result = CorbaConstants.NT_CORBA_LONG;
        }
        break;
    case IDLTokenTypes.LITERAL_unsigned:
        AST node2 = node.getNextSibling();
        if (node2 != null && node2.getType() == IDLTokenTypes.LITERAL_short) {
            // unsigned short
            result = CorbaConstants.NT_CORBA_USHORT;
        } else if (node2 != null && node2.getType() == IDLTokenTypes.LITERAL_long) {
            AST node3 = node2.getNextSibling();
            if (node3 != null && node3.getType() == IDLTokenTypes.LITERAL_long) {
                // unsigned long long
                result = CorbaConstants.NT_CORBA_ULONGLONG;
            } else {
                // unsigned long
                result = CorbaConstants.NT_CORBA_ULONG;
            }
        } else {
            // TBD: we should never get here
        }
        break;
    case IDLTokenTypes.LITERAL_short:
        result = CorbaConstants.NT_CORBA_SHORT;
        break;
    case IDLTokenTypes.LITERAL_float:
        result = CorbaConstants.NT_CORBA_FLOAT;
        break;
    case IDLTokenTypes.LITERAL_double:
        result = CorbaConstants.NT_CORBA_DOUBLE;
        break;
    case IDLTokenTypes.LITERAL_char:
        result = CorbaConstants.NT_CORBA_CHAR;
        break;
    case IDLTokenTypes.LITERAL_wchar:
        result = CorbaConstants.NT_CORBA_WCHAR;
        break;
    case IDLTokenTypes.LITERAL_string:
        result = CorbaConstants.NT_CORBA_STRING;
        break;
    case IDLTokenTypes.LITERAL_wstring:
        result = CorbaConstants.NT_CORBA_WSTRING;
        break;
    case IDLTokenTypes.LITERAL_boolean:
        result = CorbaConstants.NT_CORBA_BOOLEAN;
        break;
    case IDLTokenTypes.LITERAL_octet:
        result = CorbaConstants.NT_CORBA_OCTET;
        break;
    case IDLTokenTypes.LITERAL_any:
        result = CorbaConstants.NT_CORBA_ANY;
        break;
    default:
        // TBD
        break;
    }
    return result;
}
 
Example 18
Source File: DefineGrammarItemsWalker.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final void rewrite_alternative(AST _t) throws RecognitionException {
	
	GrammarAST rewrite_alternative_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t;
	GrammarAST a = null;
	
	try {      // for error handling
		if (_t==null) _t=ASTNULL;
		if (((_t.getType()==ALT))&&(grammar.buildAST())) {
			AST __t135 = _t;
			a = _t==ASTNULL ? null :(GrammarAST)_t;
			match(_t,ALT);
			_t = _t.getFirstChild();
			{
			if (_t==null) _t=ASTNULL;
			switch ( _t.getType()) {
			case OPTIONAL:
			case CLOSURE:
			case POSITIVE_CLOSURE:
			case LABEL:
			case ACTION:
			case STRING_LITERAL:
			case CHAR_LITERAL:
			case TOKEN_REF:
			case RULE_REF:
			case TREE_BEGIN:
			{
				{
				int _cnt138=0;
				_loop138:
				do {
					if (_t==null) _t=ASTNULL;
					if ((_t.getType()==OPTIONAL||_t.getType()==CLOSURE||_t.getType()==POSITIVE_CLOSURE||_t.getType()==LABEL||_t.getType()==ACTION||_t.getType()==STRING_LITERAL||_t.getType()==CHAR_LITERAL||_t.getType()==TOKEN_REF||_t.getType()==RULE_REF||_t.getType()==TREE_BEGIN)) {
						rewrite_element(_t);
						_t = _retTree;
					}
					else {
						if ( _cnt138>=1 ) { break _loop138; } else {throw new NoViableAltException(_t);}
					}
					
					_cnt138++;
				} while (true);
				}
				break;
			}
			case EPSILON:
			{
				GrammarAST tmp74_AST_in = (GrammarAST)_t;
				match(_t,EPSILON);
				_t = _t.getNextSibling();
				break;
			}
			default:
			{
				throw new NoViableAltException(_t);
			}
			}
			}
			GrammarAST tmp75_AST_in = (GrammarAST)_t;
			match(_t,EOA);
			_t = _t.getNextSibling();
			_t = __t135;
			_t = _t.getNextSibling();
		}
		else if (((_t.getType()==ALT||_t.getType()==TEMPLATE||_t.getType()==ACTION))&&(grammar.buildTemplate())) {
			rewrite_template(_t);
			_t = _retTree;
		}
		else if ((_t.getType()==ETC)) {
			GrammarAST tmp76_AST_in = (GrammarAST)_t;
			match(_t,ETC);
			_t = _t.getNextSibling();
			if (!(this.blockLevel==1))
			  throw new SemanticException("this.blockLevel==1");
		}
		else {
			throw new NoViableAltException(_t);
		}
		
	}
	catch (RecognitionException ex) {
		if (inputState.guessing==0) {
			reportError(ex);
			if (_t!=null) {_t = _t.getNextSibling();}
		} else {
		  throw ex;
		}
	}
	_retTree = _t;
}
 
Example 19
Source File: ANTLRTreePrinter.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final void ruleScopeSpec(AST _t) throws RecognitionException {
	
	GrammarAST ruleScopeSpec_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t;
	
	try {      // for error handling
		AST __t63 = _t;
		GrammarAST tmp47_AST_in = (GrammarAST)_t;
		match(_t,SCOPE);
		_t = _t.getFirstChild();
		{
		if (_t==null) _t=ASTNULL;
		switch ( _t.getType()) {
		case ACTION:
		{
			GrammarAST tmp48_AST_in = (GrammarAST)_t;
			match(_t,ACTION);
			_t = _t.getNextSibling();
			break;
		}
		case 3:
		case ID:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(_t);
		}
		}
		}
		{
		_loop66:
		do {
			if (_t==null) _t=ASTNULL;
			if ((_t.getType()==ID)) {
				GrammarAST tmp49_AST_in = (GrammarAST)_t;
				match(_t,ID);
				_t = _t.getNextSibling();
			}
			else {
				break _loop66;
			}
			
		} while (true);
		}
		_t = __t63;
		_t = _t.getNextSibling();
	}
	catch (RecognitionException ex) {
		reportError(ex);
		if (_t!=null) {_t = _t.getNextSibling();}
	}
	_retTree = _t;
}
 
Example 20
Source File: AssignTokenTypesWalker.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final void modifier(AST _t) throws RecognitionException {
	
	GrammarAST modifier_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t;
	
	try {      // for error handling
		if (_t==null) _t=ASTNULL;
		switch ( _t.getType()) {
		case LITERAL_protected:
		{
			GrammarAST tmp28_AST_in = (GrammarAST)_t;
			match(_t,LITERAL_protected);
			_t = _t.getNextSibling();
			break;
		}
		case LITERAL_public:
		{
			GrammarAST tmp29_AST_in = (GrammarAST)_t;
			match(_t,LITERAL_public);
			_t = _t.getNextSibling();
			break;
		}
		case LITERAL_private:
		{
			GrammarAST tmp30_AST_in = (GrammarAST)_t;
			match(_t,LITERAL_private);
			_t = _t.getNextSibling();
			break;
		}
		case FRAGMENT:
		{
			GrammarAST tmp31_AST_in = (GrammarAST)_t;
			match(_t,FRAGMENT);
			_t = _t.getNextSibling();
			break;
		}
		default:
		{
			throw new NoViableAltException(_t);
		}
		}
	}
	catch (RecognitionException ex) {
		reportError(ex);
		if (_t!=null) {_t = _t.getNextSibling();}
	}
	_retTree = _t;
}