2.1. Lexical Structure

2.1.1. Identifiers

Identifiers start with an alphabetic character (and not the symbol ‘_’) followed by any number of alphabetic characters, ‘_’ or digits ([0-9]). daScript is a case sensitive language meaning that the lowercase and uppercase representation of the same alphabetic character are considered different characters. For instance, “foo”, “Foo” and “fOo” are treated as 3 distinct identifiers.

2.1.2. Keywords

The following words are reserved and cannot be used as identifiers:

struct

def

recover

panic

let

var

continue

break

finally

new

delete

enum

enum

for

while

if

else

elif

options

null

deref

return

typeinfo

this

cast

upcast

reinterpret

operator

in

scope

require

true

false

typedef

with

override

type

expect

auto

include

where

addr

assert

invoke

Keywords and types are covered in detail later in this document.

2.1.3. Operators

daScript recognizes the following operators:

!

:=

??

==

&

>=

<=

>

->

+

+=

-

-=

/

/=

*

*=

|>

<|

++

--

<-

=

&

^

|

~

>>

.

?.

??

2.1.4. Other tokens

Other significant tokens are:

{

}

[

]

.

:

::

'

;

"

]]

[[

2.1.5. Literals

daScript accepts integer numbers, unsigned integers, floating and double point numbers and string literals.

34

Integer number(base 10)

0xFF00A120

Unsigned Integer number(base 16)

0753

Integer number(base 8)

'a'

Integer number

1.52

Floating point number

1.e2

Floating point number

1.e-2

Floating point number

1.52d

Double point number

1.e2d

Double point number

1.e-2d

Double point number

"I'm a string"

String

@" I'm a multiline verbatim string "

String

Pesudo BNF

IntegerLiteral        ::=  [1-9][0-9]* | '0x' [0-9A-Fa-f]+ | ''' [.]+ ''' | 0[0-7]+
FloatLiteral          ::=  [0-9]+ '.' [0-9]+
FloatLiteral          ::=  [0-9]+ '.' 'e'|'E' '+'|'-' [0-9]+
StringLiteral         ::=  '"'[.]* '"'
VerbatimStringLiteral ::=  '@''"'[.]* '"'

2.1.6. Comments

A comment is text that the compiler ignores but that is useful for programmers. Comments are normally used to embed annotations in the code. The compiler treats them as white space.

A comment can be /* (slash, asterisk) characters, followed by any sequence of characters (including new lines), followed by the */ characters. This syntax is the same as ANSI C:

/*
This is
a multiline comment.
This lines will be ignored by the compiler.
*/

A comment can also be // (two slashes) characters, followed by any sequence of characters. A new line not immediately preceded by a backslash terminates this form of comment. It is commonly called a “single-line comment.”:

// This is a single line comment. This line will be ignored by the compiler.

2.1.7. Semantic indenting

daScript follows semantic indenting (much like Python). That means, that logical blocks are arranged with a same indenting, and if control statement requires nesting of block (such as body of function, block, if, for, etc.) it have to be indented one step more. Indenting step is part of options of program, so it is either 2, 4 or 8, but always the same for whole file. Default indenting is 4, and can be globally overriden per project.