background preloader

Haxe

Facebook Twitter

Nicolas Cannasse Blog. Haxe. API. Language Reference. NekoVM. Specification. Syntax The syntax of the Neko language was designed to be easy to parse and easy to generate. It is not specifically designed to be written by a programmer, but rather to be generated from a higher level language. For example, one could write easily a PHP-to-Neko or a Java-to-Neko converter that would generate equivalent code but with Neko syntax and semantics rather than those of PHP or Java. In particular, there are not multiple levels of expression, as in C. Every statement is also an expression, thus enabling some constructs that are not possible in other languages (for example : return if(x) { ... } else { ... }).

The syntax is parsed using a left-to-right LL(1) parser. Random notes : _ signifies an empty expression continue and break are not allowed outside of a while loop. Values A value in Neko can be one of the following : Null : the special value null is used for uninitialized variables as well as programmer/language specific coding techniques. Some Notes : Execution Flow Values : Documentation.

Before reading this part of the documentation, it is recommend to have already read the C FFI Documentation or to have a good knowledge of it. Running the VM The Neko Virtual Machine is one binary called neko included in the Neko distribution. You can call it anytime using neko (file) in order to execute the specified bytecode file. Bytecode files are precompiled Neko sources and have the .n extension. They are searched in local directories but also using the NEKOPATH environment variable which can list several search paths separated by :.

Each bytecode .n file is also called a Module. Libraries Each .ndll file is neko library. Exports Each Neko module has a global object named $exports. $exports.log = function() { $print("log test") }; Loaders Each Neko module have a loader which is an object that can be used to load other Neko modules and C primitives. In order to load a Module, you can simply call the loadmodule method, which takes two parameters. Custom loaders Embedding the VM NekoVM API. Mod_neko. Mod_neko is an Apache module for Neko. It means it is possible to run Neko programs on the server side in order to serve webpages using Apache. Here’s a step-by-step tutorial on how to configure and use Mod_neko. Quick configuration If you don’t have mod_neko compiled or you don’t want to setup Apache, you can use a mod_neko emulator by using the Neko Web Server.

This is a very small web server that is running localy for development purposes only. It mimics the same API as mod_neko so you can use it instead. In order to start the server, simply run the following command : nekotools server This should start the local server, by default on the localhost on port 2000 so you can browse the configuration page by visiting Linux Installation Apache configuration If you want to use Apache with mod_neko, once Neko is correctly configured, you can edit your Apache configuration httpd.conf in order to add mod_neko.

Some tests $print("Hello Mod_neko ! ")