Пример #1
0
String*
Enum::determineDeclaration()
{
	StringBuffer sb;

	IPIterator<SourceToken>* it = this->cu.getAST().getTree().children( *this->p );
	bool loop = true;
	while ( loop && it->hasNext() )
	{
		IPosition<SourceToken>* p = it->next();
		{
			SourceToken& token = p->getElement();
			
			switch ( token.getTokenType() )
			{
			case SourceToken::KEYWORD:
			case SourceToken::NAME:
			case SourceToken::SPACE:
			case SourceToken::WORD:
				sb.append( token.getValue() );
				break;
			
			case SourceToken::BLOCK:
				break;
			
			default:
				break;
			}
		}
		delete p;
	}
	delete it;
	
	return sb.asString();
}
Пример #2
0
String*
SourceToken::getEscapedValue() const
{
    StringBuffer sb;

    long max = this->value->getLength();
    for ( long i=0; i < max; i++ )
    {
        long ch = this->value->charAt((int)i);

        switch ( ch )
        {
        case '\n':
            sb.append( '\\' );
            sb.append( 'n' );
            break;
        case '\t':
            sb.append( '\\' );
            sb.append( 't' );
            break;
        default:
            sb.append( ch );
        }
    }

    return sb.asString();
}
Пример #3
0
void
Enum::setContent( const String& content )
{
	StringBuffer sb;
	sb.append( content );
	sb.append( '\n' );
	
	delete this->content;
	this->content = sb.asString();
}
Пример #4
0
String*
AST::getIndent() const
{
	StringBuffer sb;
	long len = this->indent->size();
	for ( long i=0; i < len; i++ )
	{
		sb.append( this->indent->get(i).getValue() );
	}
	return sb.asString();
};
Пример #5
0
	static void parseParameters( ITree<SourceToken>& ast, IPosition<SourceToken>& parent, SourceTokenizer& tokenizer )
	{
		StringBuffer sb;
	
		bool loop = true;
		while ( loop && tokenizer.hasMoreTokens() )
		{
			const SourceToken&      token = tokenizer.peekNextToken();
			SourceToken::TokenType  ttype = token.getTokenType();
			IPosition<SourceToken>* stmt  = NULL;
			
			switch ( ttype )
			{
			case SourceToken::BLANKLINE:
				delete ast.addChild( parent, tokenizer.nextToken() );
				break;
			case SourceToken::TAB:
				delete ast.addChild( parent, tokenizer.nextToken() );
				break;
			case SourceToken::SPACE:
				delete ast.addChild( parent, tokenizer.nextToken() );
				break;
			case SourceToken::ENDEXPRESSION:
				delete ast.addChild( parent, tokenizer.nextToken() );
				loop = false;
				break;
			case SourceToken::NEWLINE:
				delete ast.addChild( parent, tokenizer.nextToken() );
				break;
			default:
				stmt = ast.addChild( parent, new SourceToken( SourceToken::PARAMETER, new String() ) );
				String* param_type = parseParameter( ast, *stmt, tokenizer );
				{
					sb.append( *param_type );
					sb.append( "," );

//					if ( ! param_type->contentEquals( "" ) )
//					{
//						stmt->getElement().setType( SourceToken::PARAMETER );
//					}
				}

				delete param_type;
				countup( ast, *stmt );
				delete stmt;
			}
		}
		
		sb.removeLast();
		parent.getElement().setValue( sb.asString() );
	}
Пример #6
0
	static void parseExpression( ITree<SourceToken>& ast, IPosition<SourceToken>& parent, SourceTokenizer& tokenizer )
	{
		StringBuffer sb;
	
		bool loop = true;
		while ( loop && tokenizer.hasMoreTokens() )
		{
			const SourceToken&      token = tokenizer.peekNextToken();
			SourceToken::TokenType  ttype = token.getTokenType();
			IPosition<SourceToken>* stmt  = NULL;
			
			switch ( ttype )
			{
			case SourceToken::ENDEXPRESSION:
				delete ast.addChild( parent, tokenizer.nextToken() );
				loop = false;
				break;

			case SourceToken::ENDBLOCK:
				loop = false;
				break;

			case SourceToken::BLANKLINE:
			case SourceToken::TAB:
			case SourceToken::SPACE:
			case SourceToken::NEWLINE:
				delete ast.addChild( parent, tokenizer.nextToken() );
				break;

			case SourceToken::SYMBOL:
				delete ast.addChild( parent, tokenizer.nextToken() );

			default:
				stmt = ast.addChild( parent, new SourceToken( SourceToken::CLAUSE, new String() ) );
				parseStatement( ast, *stmt, tokenizer, true );
				countup( ast, *stmt );
				delete stmt;
			}
		}
		
		sb.removeLast();
		parent.getElement().setValue( sb.asString() );
	}
Пример #7
0
static void handleStartParameters( ITree<SourceToken>& ast, IPosition<SourceToken>& parent, SourceTokenizer& tokenizer )
{
	IPosition<SourceToken>* params = ast.addChild( parent, new SourceToken( SourceToken::PARAMETERS, new String() ) );
	{
		delete ast.addChild( *params, tokenizer.nextToken() );
		parseTrailingWhitespace( ast, *params, tokenizer );
		parseParameters( ast, *params, tokenizer );
		parseTrailingWhitespace( ast, *params, tokenizer );

		StringBuffer sb;
		sb.append( parent.getElement().getValue() );
		sb.append( '(' );
		sb.append( params->getElement().getValue() );
		sb.append( ')' );
		
		parent.getElement().setValue( sb.asString() );
	}
	countup( ast, *params );
	delete params;
}