lestes::lang::cplus::lex::ucn_token Class Reference

Single source character token. More...

#include <ucn_token.hh>

Inheritance diagram for lestes::lang::cplus::lex::ucn_token:

lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn > lestes::std::object lestes::std::mem::keystone List of all members.

Public Types

enum  token_types {
  TOK_EOF = 0, TOK_TRANSLATED = 1, TOK_NOT_EOF = 2, TOK_BASIC = 3,
  TOK_ERROR = 4
}
 Token type constants. More...
typedef ptr< ::lestes::msg::messageerror_type
 The type of stored error message.

Public Member Functions

error_type error_get (void) const
 Returns error for token.
ptr< ucn_tokenclone_type (const type_type &a_type) const
 Returns copy of token with changed type.
ptr< ucn_tokenclone_value (const value_type &a_value) const
 Returns copy of token with changed value.
ptr< ucn_tokenclone_location (const location_type &a_location) const
 Returns copy of token with changed location.
bool equals (const ptr< ucn_token > &rhs) const
 Tests equality.

Static Public Member Functions

static ptr< ucn_tokencreate (const type_type &a_type)
 Returns new token, initializes with token type.
static ptr< ucn_tokencreate (const type_type &a_type, const value_type &a_value)
 Returns new token, initializes with token type and token value.
static ptr< ucn_tokencreate (const type_type &a_type, const value_type &a_value, const location_type &a_location)
 Returns new token, initializes with location, token type and value.
static ptr< ucn_tokencreate_error (const error_type &a_error, const location_type &a_location)
 Returns new error token, initializes with error and location.
static ptr< ucn_tokencreate_error (const error_type &a_error)
 Returns new error token, initializes with the error.

Protected Member Functions

 ucn_token (const location_type &a_location, const type_type &a_type, const value_type &a_value)
 Creates the object, initializes with location, type and value.
 ucn_token (const location_type &a_location, const error_type &a_error)
 Creates the object, initializes with location and error.
virtual void gc_mark (void)
 Marks the object.

Private Member Functions

 ucn_token (const ucn_token &)
 Hides copy constructor.
ucn_tokenoperator= (const ucn_token &)
 Hides assignment operator.

Private Attributes

srp< ::lestes::msg::messageerror
 Message to report for token.

Detailed Description

Single source character token.

Represents single source character token. For character translation and other processing before lex phase.

Definition at line 56 of file ucn_token.hh.


Member Typedef Documentation

typedef ptr< ::lestes::msg::message > lestes::lang::cplus::lex::ucn_token::error_type

The type of stored error message.

Definition at line 59 of file ucn_token.hh.


Member Enumeration Documentation

enum lestes::lang::cplus::lex::ucn_token::token_types

Token type constants.

Enumerator:
TOK_EOF  End of file.
TOK_TRANSLATED  Anything which is not basic source character.
TOK_NOT_EOF  Any character in early stages of processing.
TOK_BASIC  Basic source character.
TOK_ERROR  Token for propagation of messages.

Definition at line 82 of file ucn_token.hh.

00082                          {
00083                 //! End of file.
00084                 TOK_EOF = 0,
00085                 //! Anything which is not basic source character.
00086                 TOK_TRANSLATED = 1,
00087                 //! Any character in early stages of processing.
00088                 TOK_NOT_EOF = 2,
00089                 //! Basic source character.
00090                 TOK_BASIC = 3,
00091                 //! Token for propagation of messages.
00092                 TOK_ERROR = 4
00093         };


Constructor & Destructor Documentation

lestes::lang::cplus::lex::ucn_token::ucn_token ( const location_type a_location,
const type_type a_type,
const value_type a_value 
) [protected]

Creates the object, initializes with location, type and value.

Creates the object, initializes with location, type and value.

Precondition:
a_type != TOK_ERROR
Postcondition:
a_error == NULL
Parameters:
a_location The initial location of the token.
a_type The initial type of the token.
a_value The initial value of the token.

Definition at line 50 of file ucn_token.cc.

Referenced by clone_location(), clone_type(), clone_value(), create(), and create_error().

00051                                           :
00052         basic_ucn_token(a_location,(lassert(a_type != TOK_ERROR),a_type),a_value),
00053         error()
00054 {
00055 }

lestes::lang::cplus::lex::ucn_token::ucn_token ( const location_type a_location,
const error_type a_error 
) [protected]

Creates the object, initializes with location and error.

Creates the object, initializes with location and error message.

Precondition:
a_error != NULL
Parameters:
a_location The location of the token.
a_error The error message.

Definition at line 63 of file ucn_token.cc.

00063                                                                               :
00064         basic_ucn_token(a_location,TOK_ERROR,0),
00065         error(checked(a_error))
00066 {
00067 }

lestes::lang::cplus::lex::ucn_token::ucn_token ( const ucn_token  )  [private]

Hides copy constructor.


Member Function Documentation

ucn_token::error_type lestes::lang::cplus::lex::ucn_token::error_get ( void   )  const

Returns error for token.

Returns error for an error token.

Precondition:
type_get() == TOK_ERROR
Returns:
The error assigned to the token.

Definition at line 83 of file ucn_token.cc.

References error, lassert, TOK_ERROR, and lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >::type_get().

Referenced by clone_location().

00084 {
00085         lassert(type_get() == TOK_ERROR);
00086         lassert(error);
00087         return error;
00088 }

ptr< ucn_token > lestes::lang::cplus::lex::ucn_token::clone_type ( const type_type a_type  )  const

Returns copy of token with changed type.

Returns copy of this token with new type.

Precondition:
type_get() != TOK_ERROR
Returns:
The token with new value.

Definition at line 117 of file ucn_token.cc.

References lassert, lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >::location_get(), TOK_ERROR, lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >::type_get(), ucn_token(), and lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >::value_get().

00118 {
00119         lassert(type_get() != TOK_ERROR);
00120         return new ucn_token(location_get(),a_type,value_get());
00121 }

ptr< ucn_token > lestes::lang::cplus::lex::ucn_token::clone_value ( const value_type a_value  )  const

Returns copy of token with changed value.

Returns copy of this token with new value.

Precondition:
type_get() != TOK_ERROR
Returns:
The token with new value.

Definition at line 128 of file ucn_token.cc.

References lassert, lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >::location_get(), TOK_ERROR, lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >::type_get(), and ucn_token().

00129 {
00130         lassert(type_get() != TOK_ERROR);
00131         return new ucn_token(location_get(),type_get(),a_value);
00132 }

ptr< ucn_token > lestes::lang::cplus::lex::ucn_token::clone_location ( const location_type a_location  )  const

Returns copy of token with changed location.

Returns copy of this token with new location.

Returns:
The token with new value.

Definition at line 138 of file ucn_token.cc.

References error_get(), TOK_ERROR, lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >::type_get(), ucn_token(), and lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >::value_get().

00139 {
00140         if (type_get() == TOK_ERROR)
00141                 return new ucn_token(a_location,error_get());
00142         return new ucn_token(a_location,type_get(),value_get());
00143 }

ptr< ucn_token > lestes::lang::cplus::lex::ucn_token::create ( const type_type a_type  )  [static]

Returns new token, initializes with token type.

Returns new token, initializes with token type.

Postcondition:
is_equal(type_get(),a_type)
Parameters:
a_type The initial token type.
Returns:
New token initialized with token type.

Definition at line 151 of file ucn_token.cc.

References ucn_token().

Referenced by lestes::lang::cplus::lex::string_source::read(), lestes::lang::cplus::lex::stream_source::read(), lestes::lang::cplus::lex::special_tokens::read(), and lestes::lang::cplus::lex::pre_lex::read().

00152 {
00153         return new ucn_token(location_type(),a_type,value_type());
00154 }

ptr< ucn_token > lestes::lang::cplus::lex::ucn_token::create ( const type_type a_type,
const value_type a_value 
) [static]

Returns new token, initializes with token type and token value.

Returns new token, initializes with token type and token value.

Postcondition:
is_equal(type_get(),a_type)

is_equal(value_get(),a_value)

Parameters:
a_type The initial token type.
a_value The initial value.
Returns:
A new token initialized with token type and value.

Definition at line 164 of file ucn_token.cc.

References ucn_token().

00165 {
00166         return new ucn_token(location_type(),a_type,a_value);
00167 }

ptr< ucn_token > lestes::lang::cplus::lex::ucn_token::create ( const type_type a_type,
const value_type a_value,
const location_type a_location 
) [static]

Returns new token, initializes with location, token type and value.

Returns new token, initializes with location, token type and token value.

Postcondition:
is_equal(type_get(),a_type)

is_equal(value_get(),a_value)

is_equal(location_get(),a_location)

Parameters:
a_type The initial token type.
a_value The initial token value.
a_location The initial location.
Returns:
A new token initialized with location, token type and token value.

Definition at line 179 of file ucn_token.cc.

References ucn_token().

00181 {
00182         return new ucn_token(a_location,a_type,a_value);
00183 }

ptr< ucn_token > lestes::lang::cplus::lex::ucn_token::create_error ( const error_type a_error,
const location_type a_location 
) [static]

Returns new error token, initializes with error and location.

Returns new token, initializes with error and location.

Postcondition:
is_equal(error_get(),a_error)

is_equal(location_get(),a_location)

Parameters:
a_error The error message.
a_location The location.
Returns:
A new token initialized with location and error message.

Definition at line 193 of file ucn_token.cc.

References ucn_token().

Referenced by lestes::lang::cplus::lex::special_tokens::read(), lestes::lang::cplus::lex::pre_lex::read(), lestes::lang::cplus::lex::encoder_utf8::read(), lestes::lang::cplus::lex::encoder_host::read(), and lestes::lang::cplus::lex::encoder_ascii7::read().

00194 {
00195         return new ucn_token(a_location,a_error);
00196 }

ptr< ucn_token > lestes::lang::cplus::lex::ucn_token::create_error ( const error_type a_error  )  [static]

Returns new error token, initializes with the error.

Returns new token, initializes with error.

Postcondition:
is_equal(error_get(),a_error)
Parameters:
a_error The error message.
a_location The location.
Returns:
A new token initialized with location and error message.

Definition at line 205 of file ucn_token.cc.

References ucn_token().

00206 {
00207         return new ucn_token(NULL,a_error);
00208 }

bool lestes::lang::cplus::lex::ucn_token::equals ( const ptr< ucn_token > &  rhs  )  const

Tests equality.

Tests equality of the token.

Parameters:
rhs The token to compare with.
Returns:
true If both tokens are equal.

Definition at line 215 of file ucn_token.cc.

References lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >::equals().

00216 {
00217         return basic_ucn_token::equals(rhs.dncast<basic_ucn_token>());
00218 }

void lestes::lang::cplus::lex::ucn_token::gc_mark ( void   )  [protected, virtual]

Marks the object.

Marks the object

Reimplemented from lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >.

Definition at line 72 of file ucn_token.cc.

References error, and lestes::lang::cplus::lex::basic_token< lc_host_uint_least9, ptr< simple_location >, ucn >::gc_mark().

00073 {
00074         error.gc_mark();
00075         basic_ucn_token::gc_mark();
00076 }

ucn_token& lestes::lang::cplus::lex::ucn_token::operator= ( const ucn_token  )  [private]

Hides assignment operator.


Member Data Documentation

srp< ::lestes::msg::message > lestes::lang::cplus::lex::ucn_token::error [private]

Message to report for token.

Definition at line 103 of file ucn_token.hh.

Referenced by error_get(), and gc_mark().


The documentation for this class was generated from the following files:
Generated on Mon Feb 12 18:24:19 2007 for lestes by doxygen 1.5.1-20070107