Skip to content

Latest commit

 

History

History
131 lines (97 loc) · 4.43 KB

README-Syntax.md

File metadata and controls

131 lines (97 loc) · 4.43 KB

LOGO

1. Syntax

1.1. Introduction

MinitScript takes a simple approach regarding its syntax. There are no syntax keywords or similar. Everything, despite variables, constants and operators, is build around the idea of methods, functions and callables, which are identified by a name, including some namespace information, and arguments surrounded by brackets like:

E.g. namespace.functionName($arg0, ..., $argN)

1.2. Statements

You can simply list statements line by line.

	console.printLine("Hi there. Who has some serious interest in MinitScripting?")
	console.printLine("Me!")
	console.printLine("Me not!")

You can also separate statements using the semicolon.

	# one line, one statement
	console.printLine("Hi there. Who has some serious interest in MinitScripting?")
	# see line below with multiple statements
	console.printLine("Me!"); console.printLine("Me not!"); console.printLine("Never ever!")

This can also be used like:

	$array = [1,2,3]
	forEach($entry in $array); console.printLine($entry); end

1.3. Methods, functions and callables.

A method is provided by a C++ class and its member method, hence the name. In the documentation you find them in Built-in functions section. This sounds a bit confusing, but makes sense.

Methods (and possibly a custom data type) can also be used to generate a classes like API, just look in the Built-in classes section.

Function and callables are defined by the scripts itself. Callables are basically public functions for script interoperability with some more safety checks. See Functions section.

In combination with map datatype, you can also generate classes like objects in MinitScript language. See Classes section.

1.4. Top level script syntax

At top level MinitScript can take the following syntax:

  • function: ...
  • callable: ...
  • stacklet: ...

1.4.1 Functions and callables

At top level script scope we still can define functions like:

function: factorial($value)
	if ($value == 0)
		return(1)
	end
	return($value * factorial($value - 1))
end

and callables like:

callable: helloWorldFunction()
	console.printLine("helloWorldFunction(): Hello world")
end

For more information see Functions section.

1.4.2 Main function

The entry point for MinitScript scripts is the main function, if events are disabled, e.g. in stock MinitScript distribution. Means the first thing that is called in stock MinitScript is the script's main function.

# main
function: main()
	console.printLine("Hello world")
end

1.6. Additional documentation

To have more information, I would suggest you to read the following sections next or on demand.

2. Links

2.1. Language documentation

2.2. Other links