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

Original post by WitchLordIt'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]

0

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.

0

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.