[antlr-interest] small CharInputBuffer class
John Lambert
johnl at jbase.com
Tue Oct 2 11:06:44 PDT 2001
Ruslan,
Looks pretty much the same as what I use, except I suggest you use unsigned
chars to avoid signe extension problems.
Regards,
John Lambert
-----Original Message-----
From: Ruslan Zasukhin [mailto:sunshine at public.kherson.ua]
Sent: Tuesday, October 02, 2001 10:49 AM
To: antlr-interest at yahoogroups.com; Ric Klaren
Subject: [antlr-interest] small CharInputBuffer class
Hi Ric,
I have look on CharBuffer class...
Yes it want to get istream as parameter, you suugest to use istringstream
class for RAM based string...
But istringstream want to get only std::string class.
But I have just char* or my own string class.
Conclusion: I do not want to use CharBuffer class :-)
This is my implementation of InputBuffer subclass.
Please look if I correctly work with EOF. It must be -1, yes ?
It seems to me, my class will work also faster, than with istream.
--------------------------------------------------------------
class OBL_InputBuffer : : public InputBuffer
{
public://///////////////////////////////////////////////////////////////////
OBL_InputBuffer( char* inStr, ulong inLength ) :
mStrPtr(inStr),
mEndPtr(inStr + inLength)
{
}
virtual int getChar( void )
{
// EOF is -1.
return (mStrPtr < mEndPtr) ? *mStrPtr++ : -1;
}
protected://////////////////////////////////////////////////////////////////
char* mStrPtr;
char* mEndPtr;
};
--
Best regards,
Ruslan Zasukhin
-------------------------
Paradigma.
e-mail: ruslan at paradigmasoft.com
web : http://www.paradigmasoft.com
To subscribe to the Valentina mail list
send a letter to valentina-on at lists.macserve.net
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list