Jump to content
  • Advertisement
Sign in to follow this  
Suudy

Character literals and uint8

This topic is 4848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If I create a uint8, and try to assign a character literal, I get an error. For example:
uint8 fill;
fill = '0';
I get the following error: "Error : Expected expression value" This isn't a critical problem (I'm using setfill, i.e. "cout << std.setfill('0')"), since I can substitute the ASCII equivalent in hex, decimal, whatever. I'm just curious if it should be allowed.

Share this post


Link to post
Share on other sites
Advertisement
It's funny when people mistake questions about AngelScript syntax for questions about C++. [wink] (As a moderator I can see deleted posts.)

Single character literals are not implemented in the AngelScript syntax yet. I haven't decided if I will do so either.

Currently I suggest that you expose a function like 'uint8 ascii(string&in)' that returns the ascii code for the first character in the string, or use numeric constants.

Share this post


Link to post
Share on other sites
Quote:
Original post by WitchLord
It's funny when people mistake questions about AngelScript syntax for questions about C++. [wink] (As a moderator I can see deleted posts.)

I don't understand exactly what you mean [looksaround]. Granted, AngelScript is not C++, and with such close syntax, I guess I went with the same syntax.

Quote:
Original post by WitchLordSingle character literals are not implemented in the AngelScript syntax yet. I haven't decided if I will do so either.

I'm no compiler expert, and what you have so far is great. There's no great need for them (we can make do with numeric constants), but I wasn't sure if it was available. There's no mention in the ScriptWriter's manual, but I was hoping... [grin]

Share this post


Link to post
Share on other sites
I'm sorry about the confusion, I should have explained better. Just before my answer to your question someone else answered. That person mistook your question for being about C++, and answered it as such. However, he (or she) realized his own mistake and deleted the post before anyone could see it, except for those of us who are moderators. [wink]

Character literals wouldn't be difficult to implement, I just can't decide wether I want them or not. I've come to know that in C/C++ character literals are really interpreted by the preprocessor, so the underlying compiler really don't understand them. AngelScript could support them in the same way, and in fact, with Deyja's preprocessor it already does.

Share this post


Link to post
Share on other sites
Indeed it does. I ran across this same problem some time back, and asked WL about it. After a bit of research, I discovered that in C++ the preprocessor handles it, so I added it to mine. It does it in the simplest way imaginable. When it detects a ' character, it assumes the next character is the one to encode, and the one after it is another '. It does absolutly no error checking, and if you do something like 'lotsofcharacters' you will get some rather hard to decode error in angelscript. It does support escapes, but only newline, carriage return, and tab.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!