Keyword syntax (DSL)

Features of associative memory

The syntax of the NewLang language is based on strict rules without the use of keywords, and no matter how logical it may seem, association by keywords is much easier to remember, for example, if, than the combination minus minus right angle bracket –>. Because of this, it makes sense to use not a “pure” basic syntax, but a more familiar dialect with the use of keywords.

NewLang already contains a set of macros that extend the basic rule-based syntax of NewLang, a set of predefined keywords as in classical programming languages, which can be adapted or supplemented to suit your own subject area.

Constants

  • @true - 1

  • @yes - 1

  • @false - 0

  • @no - 0

  • @this или @self - Current object

  • @super - Parent object

  • @latter or @last- Result of the last operation

Logical operators

  • @and - Logical AND
  • @or - Logical OR
  • @xor - Logical Exclusive OR
  • @not(value) - Logical negation

Operators

  • @if(…) - First conditional statement

  • @elif(…) - Second and all subsequent conditional statements

  • @else - Operator otherwise

  • @while(…) - Loop operator with precondition

  • @dowhile(…) - Loop operator with postcondition

  • @loop - Infinite loop operator

  • @break $label - Operator to break out of a named named block of code

  • @continue $label - Jump operator to the beginning of a named block of code

  • @return( result ) - Operator for returning a value and exiting a function

  • @throw( error ) - Operator for creating an exception and returning an error

  • @match( … ) - Expression evaluation operator

  • @case( … ) - Pattern comparison operator

  • @default - Selection operator

  • @iter(obj, … ) - Creating an iterator

  • @next(obj, … ) - Get the next element of the iterator

  • @curr(obj, … ) - Get the current iterator element

  • @first(obj) - Go to the first element of the iterator

  • @all(obj) - Get all elements of the iterator at once

Predefined macros

When the NewLang parser is running, several reserved macros are automatically generated, some of which correspond to preprocessor macros in C/C++. These predefined macros can be used as regular constants.

  • __FILE__ or __FILE_NAME__ - name and full path of the current file

  • __LINE__ or __FILE_LINE__ - contains the number of the current line in the file

  • __FILE_TIMESTAMP__ - date and time of the last modification of the current file in string representation

  • __FILE_MD5__ - md5 hash of the current file in string form

  • __COUNTER__ - an integer counter that increases its value with each access

  • __DATE__ - start date of the compiler launch (has the same value for all processed files)

  • __TIME__ - start time of the compiler launch (has the same value for all processed files)

  • __TIMESTAMP__ - date and time when the compiler started running (for example: “Fri 19 Aug 13:32:58 2016”)

  • __TIMESTAMP_ISO__ - date and time when the compiler started running in ISO format (for example: “2013-07-06T00:50:06Z”)

  • __NLC_VER__ - Older and younger version of the NewLang compiler (8-bit number, 4 bits per digit)

  • __NLC_DATE_BUILD__ - text string with the build date of the NewLang compiler (for example, “06/23/04 20:51:39”)

  • __NLC_SOURCE_GIT__ - text string with the identifier of the NewLang git repository source files used to build the compiler (for example, “v0.3.0-fef8c371”)

  • __NLC_SOURCE_BUILD__ - build date and git identifier of NewLang source files in one text line (for example, “v0.3.0-fef8c371 06/23/04 20:51:39”)