Giter Club home page Giter Club logo

neoscript's Introduction

neoscript : A Command Driven DSL

Build Coverage Status

NS relies on being parsed by a SAX parser, and drives a command based interface while parsing files.

Command

A basic command syntax is as follows:

command parameter1 parameter2 [list_parameter_1, list_parameter_2];

The command can be bound to a free function that is invoked by the engine when encountered in the file, through the neo_registry interface.

Commands can also include an optional '=' or ':' after its name for syntatic sugar:

command : invoking command; // two parameters are passed to command
command = set value to command; // space is used to seperate parameters

String parameter value can be provided in double quoted string.

command : "invoking command"; // a single parameter is passed to command

Lists are created using [] operator

command : [list of parameters] // command is passed a single parameter which is a list of 3 parameters

Named parameters can be provided as follows:

command (my_parameter_name = "my_parameter value"); // parameter is named 'my_parameter_name'

Commands can be scoped inside other commands using {} scope operator

top_level_command 
{
	internal_command
	{

	}
}

Regions

A script can contain multiple regions. Registry will callback on entering new regions. There are two kinds of regions, text and code.

Code regions are processed by the parser, and commands are only invoked inside code regions. Text content in text regions are directly passed to callbacks as is.

Regions are created by region seperator -- operator at the begining of the line:

-- code : region --

A region name has two parts sepeareted by :. The first part is the region type. A code region must have a type code. The second part is the region id. For text regions, region can be of any type other than code. A region id may contain spaces, but the trailing and preceding spaces are removed.

Templates

A script might also include templates. Templates are command group definition which are invoked based on parameters passed later in the script.

Templates are defined with the $ operator as follows:

// parameterless template
$template_name_1[] 
command ; // called without any parameters

// template with parameters
$template_name_2[parameter_A, parameter_B]
command parameter_A parameter_B
{
	new_command parameter_B;
}
$[] unnamed_template parameter_A;

template_name_1 and template_name_2 are template names. The command command will not be invoked when this definition is encountered. It can be invoked later in the file using the ^ operator. Template commands may also be unnamed, in which case they should be invoked by the command name they encompass.

^template_name_1[];
^template_name_2["value 1", "value 2"];
^unnamed_template;

Script

A complete script might look like:


-- code: code section --

$shader_definition[shader_type, file]
shader shader_type
{
	files "common.glsl" "functions.glsl" "ubos.glsl" file (optional=[enable_debugging, no_optimization]);
	type shader_type;
}

^shader_definition[vertex, "vertex.glsl"];
^shader_definition[fragment, "fragment.glsl"];

$compiler[shader, options]
compile 
{
	shader_options options;
	compile shader;
}

^compiler[vertex_shader,""];
^compiler[fragment_shader,""];

// shaders are now compiled !

neoscript's People

Contributors

obhi-d avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.