Esempio n. 1
0
	public IExpression  unary() //throws RecognitionException, TokenStreamException
{
		IExpression exp;
		
		exp = null; IExpression inner = null; UnaryOp op = UnaryOp.Plus;
		
		switch ( LA(1) )
		{
		case PLUS:
		case MINUS:
		case BNOT:
		{
			{
				switch ( LA(1) )
				{
				case PLUS:
				{
					match(PLUS);
					if (0==inputState.guessing)
					{
						op = UnaryOp.Plus;
					}
					break;
				}
				case MINUS:
				{
					match(MINUS);
					if (0==inputState.guessing)
					{
						op = UnaryOp.Minus;
					}
					break;
				}
				case BNOT:
				{
					match(BNOT);
					if (0==inputState.guessing)
					{
						op = UnaryOp.BitwiseNot;
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			inner=unary();
			if (0==inputState.guessing)
			{
				exp = new UnaryExpression(inner, op);
			}
			break;
		}
		case NUM_INT:
		case NUM_FLOAT:
		case NUM_LONG:
		case IDENT:
		case STATICIDENT:
		case INSTIDENT:
		case LITERAL_self:
		case LPAREN:
		case LCURLY:
		case LBRACK:
		case LITERAL_base:
		case STRING_LITERAL:
		case CHAR_LITERAL:
		{
			exp=primary();
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		 }
		return exp;
	}
Esempio n. 2
0
	public IExpression  not_test() //throws RecognitionException, TokenStreamException
{
		IExpression exp;
		
		exp = null; IExpression inner = null;
		
		switch ( LA(1) )
		{
		case LITERAL_not:
		case LNOT:
		{
			{
				switch ( LA(1) )
				{
				case LITERAL_not:
				{
					match(LITERAL_not);
					break;
				}
				case LNOT:
				{
					match(LNOT);
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			inner=not_test();
			if (0==inputState.guessing)
			{
				exp = new UnaryExpression(inner, UnaryOp.Not);
			}
			break;
		}
		case NUM_INT:
		case NUM_FLOAT:
		case NUM_LONG:
		case IDENT:
		case STATICIDENT:
		case INSTIDENT:
		case LITERAL_self:
		case LPAREN:
		case LCURLY:
		case PLUS:
		case MINUS:
		case BNOT:
		case LBRACK:
		case LITERAL_base:
		case STRING_LITERAL:
		case CHAR_LITERAL:
		{
			exp=comparison();
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		 }
		return exp;
	}