Angel Script BNF grammar

Started by
11 comments, last by AlphaDog 18 years, 10 months ago
Where can I get angel script's BNF grammar?
Advertisement
I don't have this fully written down. Part of it can be seen in the as_parser.h file, but it's been a while since I updated it.

It is pretty similar to the way C or C++ works though, so maybe you can use the BNF grammar for one of them as base.

What do you need it for?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

My application needs BNF grammar to generate rules automatically.
BTW, is there Poniter in Angel Script? Like ' int *lPtr; '
Pointers were removed from the AngelScript language as of version 2.0.0. Objects can use object handles instead, which are similar to pointers, but are reference counted (which is why only objects can use them).

What kind of application do you use that needs to generate rules? Is it some kind of editor?

I'll try to write a document with the complete BNF grammar, though I can't say when that would be finished. If you are interested in helping out with that document, I would be grateful.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I plan to use angel script in an automatic stock trading system as trading rule- when to buy ,when to sell,etc. I am now testing the ability of angel script. I think it is very powerful. :)

how to access simple array in host c++ application, such as 'float *a'.

I wrote the program like this , but it does not work:
...
int a[100];
engine->RegisterObjectType("int[]", sizeof(int *), asOBJ_CLASS);
engine->RegisterGlobalProperty("int[] a",&a);
...

script:

a[0]=1;


You have to register an array object. I just use the std::vector class for everything. Deyja has a class that will autmatically register it for various types.
AngelScript arrays are not compatible with C++ arrays, since AngelScript needs to do bounds-checking, etc.

If you want to be able to pass arrays between C++ and AngelScript, you'll have to override AngelScripts built-in array type with a type that both AngelScript and C++ can understand.

As Rain Dog said, you can do this by registering the std::vector implementation, using Deyja's code. That code is available in the AngelScript zip file, under /tests/test_feature/source/stdvector.h.

Regards,
Andreas

PS. I'm not sure if I'd like to let a computer program do my stock exchange business' for me [wink], but even so it is an interesting project you have going there.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

If you need to pass pointers around between your script objects. I found that wrapping boost::any in a simple object with a templated get member function seems to work well and keep things relatively type-safe. Let me know if you are interested and I'll post the code here...

~Scott
[size=1]'Behold! It is not over unknown seas but back over well-known years that your quest must go; back to the bright strange things of infancy and the quick sun-drenched glimpses of magic that old scenes brought to wide young eyes.'
I'd like to see that along with an example of how to use it.

This topic is closed to new replies.

Advertisement