lib/antlr/src/CommonAST.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
#include "antlr/config.hpp"
00009
#include "antlr/CommonAST.hpp"
00010
#include "antlr/ANTLRUtil.hpp"
00011
00012
#include <cstdlib>
00013
00014
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00015
namespace antlr {
00016
#endif
00017
00018 CommonAST::CommonAST()
00019 :
BaseAST(),
00020 ttype(
Token::INVALID_TYPE ),
00021
text("")
00022 {
00023 }
00024
00025 CommonAST::CommonAST(
RefToken t)
00026 :
BaseAST(),
00027 ttype( t->getType() ),
00028
text( t->getText() )
00029 {
00030 }
00031
00032 CommonAST::~CommonAST()
00033 {
00034 }
00035
00036 const char*
CommonAST::typeName(
void )
const
00037
{
00038
return "CommonAST";
00039 }
00040
00041 CommonAST::CommonAST(
const CommonAST& other)
00042 :
BaseAST(other), ttype(other.ttype),
text(other.
text)
00043 {
00044 }
00045
00046 RefAST CommonAST::clone(
void )
const
00047
{
00048
CommonAST *ast =
new CommonAST( *
this );
00049
return RefAST(ast);
00050 }
00051
00052 ANTLR_USE_NAMESPACE(std)string
CommonAST::getText()
const
00053
{
00054
return text;
00055 }
00056
00057 int CommonAST::getType()
const
00058
{
00059
return ttype;
00060 }
00061
00062 void CommonAST::initialize(
int t,
const ANTLR_USE_NAMESPACE(std)string& txt)
00063 {
00064
setType(t);
00065
setText(txt);
00066 }
00067
00068 void CommonAST::initialize(
RefAST t)
00069 {
00070
setType(t->getType());
00071
setText(t->getText());
00072 }
00073
00074 void CommonAST::initialize(
RefToken t)
00075 {
00076
setType(t->getType());
00077
setText(t->getText());
00078 }
00079
00080
#ifdef ANTLR_SUPPORT_XML
00081
void CommonAST::initialize(
ANTLR_USE_NAMESPACE(std)istream& in )
00082 {
00083
ANTLR_USE_NAMESPACE(std)string t1, t2, text;
00084
00085
00086 read_AttributeNValue( in, t1, text );
00087
00088
00089
int type;
00090 read_AttributeNValue( in, t1, t2 );
00091 type = ANTLR_USE_NAMESPACE(std)atoi(t2.c_str());
00092
00093
00094 this->initialize( type, text );
00095 }
00096 #endif
00097
00098 void CommonAST::setText(const ANTLR_USE_NAMESPACE(std)string& txt)
00099 {
00100
text = txt;
00101 }
00102
00103 void CommonAST::setType(
int type)
00104 {
00105
ttype = type;
00106 }
00107
00108 RefAST CommonAST::factory()
00109 {
00110
return RefAST(
new CommonAST);
00111 }
00112
00113
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00114
}
00115
#endif
00116
This file is part of the documentation for KDevelop Version 3.0.4.