Šaral 2.0 – Language Specification

ŠARAL 2.0 – Language specification

Note: This is the English translation of the original specification document in Slovak.

My specification is based on a former Šaral presentation (Slovak).

Identifier are composed from lower and uppercase characters, digits and underscores. They can start with a letter or an underscore, such as
_?[:letter:]([:digit:][:letter:]_)*.

Key words

Keywords dimenzion a stuj stay in Šaral 2.0 specification preserving backward compatibility with former Šaral specification.

Operators

Data types

First 4 types are considered as primitive, first 5 as basic, type funduš as container type.

Trinary logic

Šaral uses Three-valued logic with these values pravda, ošaľ & skoroošaľ. They represent True, False a Unknown in Kleene’s logic. That means a condition is only true if all statement have pravda value.

Variable and constants declarations

<modifier> means, either identifier <name> is a variable (meňak) or a constant (furt). By declaring furt it is required to initialize to some value.

Examples

Array declarations

It is recommended to use first declaration with funduš. Keyword dimenzion is supported preserving backward compatibilty with first Šaral version. Array dimension must be of type neskutočné numeralio.

Examples

Procedures and functions

Šaral supports functions and procedures. Looking from higher perspective they appear to be like black boxes bar (pub) – some things enter inside and sometimes something is returned outside.

First bar does not return anything, second bar after finishing returns a value, which has the same type as bar. If we want to call services of a pub bar, we do it by calling paľ do baru as a procedure or vrac mi z baru as a function. As an input argument can be used meňak of arbitrary type, bar can only return arbitrary basic type. Input arguments are passed by reference.

External functions

We can call other bars from external environments, which use different languages (types must be the same as in Šaral 2.0). If we want to taste an external bar, we call it by word inakši

Examples

Conditions

The inak part is not required.

Loops

We declare the for-loop like construct as:

variables in loop are in interval <from;to)

While loop

I/O

stdin/stdout

To print something on standard output we call ciskaj <name>, where <name> is a meňak or furt. To read from input we call vežmi <name>, where <name> is a meňak, we want to read.

2 thoughts on “Šaral 2.0 – Language Specification

  1. https://www.facebook.com/%C5%A0aral-433557560407/
    Napr.:
    Ošaľ- vyhodnocuje sa počas behu, za hodnotu konštanty alebo premennej je dosadená taká hodnota aby výraz získal hodnotu “Ne” ak je to možné.
    Pretože vyhodnocovanie logického výrazu môže byť veľmi náročné, ak je prekročená zatiaľ nešpecifikovaná hranica-hĺbka vyhodnocovania, tak sa použije pravidlo “Ta boh nezna” a výraz získa hodnotu “Ne”.

Leave a Reply

Your email address will not be published. Required fields are marked *