Skip to content

The Language

SjVer edited this page Mar 27, 2022 · 9 revisions

4 – The Language

4.1 – Lexical Conventions

Evi is free-from, meaning that spaces and comments are ignored, except in strings, in characters and as delimiters between tokens. Spaces are recognized as whitespaces, carriage returns and tabs. Only ASCII characters are accepted.

Identifiers consist of a series of alphanumeric characters or underscores, not starting with a digit. Evi has no alphanumerical keywords, so the only identifiers reserved by the compiler are the built-in data types. Next to that, Evi is case-sensitive. meaning that mystring and myString are two different identifiers.

The following characters are reserved for keysymbols, operators and other tokens:

  (   )   {   }   [   ] 
  +   -   *   /   !   ,
  &   |   ^   ?   :   
  &&  ||  ^^  <<  >>  
  ==  /=  <=  >=  ->
  ++  --  ??  ::  !!  
  @   %   =   ~   ;   ...

String literals are delimeted by double quotes and can contain any amount of any character except non-escaped double quotes. Character literals are delimeted by single quotes and can contain one single character, or an escape sequence. These escape sequences include the following:

Literal characters Interpreted character
\a Bell (alert)
\b Backspace
\e
\f Form feed
\n Newline
\r Carriage return
\t Horizontal tab
\v Vertical tab
\' Single quote
\" Double quote
\\ Backslash
\0 Null character

An integer constant can be written as decimal, hexadecimal, binary or octal. Floating-point constants can only be written in decimal and must include a radix point. Examples of valid numerical constants are the following:

  1, 123, 0001, 
  0xFF, 0xaf, 0X003D,
  0c7, 0c166, 0C0,
  0b1111, 0b1, 0B0001,
  1.256, 0.0123, 0.0

Comments can be either single-line or blocks. Single-line comments are denoted by a backslash \ and include the rest of the line, while block comments are denoted by \: and go on until the end of the file, or until :\.

4.2 – Variables And Parameters

Not unlike other languages, Evi has variables. These are named storage areas that can be manipulated. Each variable has its own type and can be assigned to or referenced anywhere in the same scope after its declaration. The name of a variable must be an identifier that is not also a type (see §4.1).

Variables can de declared with- or without an intital value (initializer):

%myvar i32 1;
%zero flt;

Uninitialized variables will contain a different zero-like value depending on their type.

Declaration of multiple variables of the same type in one line is also possible:

%a, b, c chr 'a', 'b', 'c';

Variables can be dereferenced using $ and assigned to using =. Square brackets can be used to assign to- or dereference a pointer (or array literal):

%myint i64;
=myint 5;
printf("%d\n", $myint); \ prints '5'

%mystring chr* "abc";
putchar($mystring[1]); \ prints 'b'

=mystring[2] '!';
putchar($mystring[2]); \ prints '!'

putchar({'e', 'v', 'i'}[1]); \ prints 'v'

For more on visibility of variables see §4.5.

4.3 – Statements

4.3.1 – Blocks

4.3.2 – Assignment

4.3.3 – Control Flow

4.3.4 – Loops

4.3.5 – Variable Declarations

4.4 – Expressions

4.4.1 – Arithmetic Operators

4.4.2 – Bitwise Operators

4.4.3 – Relational Operators

4.4.5 – Logical Operators

4.4.6 – The SizeOf Operator

4.4.7 – The Casting Operator

4.4.8 – Function Calls

4.4.9 – Precedence

4.5 – Visibility Rules



Next: 5 – The Standard Library

Contents

Home

1 – Introduction

2 – Hello World

3 – Basic Concepts

  3.1 – Types And Values

  3.2 – Type Modifiers

  3.3 – Arrays And Pointers

4 – The Language

  4.1 – Lexical Conventions

  4.2 – Variables And Parameters

  4.3 – Statements

    4.3.1 – Blocks

    4.3.2 – Assignment

    4.3.3 – Control Flow

    4.3.4 – Loops

    4.3.5 – Variable Declarations

  4.4 – Expressions

    4.4.1 – Arithmetic Operators

    4.4.2 – Bitwise Operators

    4.4.3 – Relational Operators

    4.4.5 – Logical Operators

    4.4.6 – The SizeOf Operator

    4.4.7 – The Casting Operator

    4.4.8 – Function Calls

    4.4.9 – Precedence

  4.5 – Visibility Rules

5 – The Standard Library

  5.1 – The Std Library

    5.1.1 – Input And Output

    5.1.2 – Mathematics

    5.1.3 – Memory Management

6 – The Preprocessor

  6.1 – Including Files

  6.2 – Setting Flags

  6.3 – Conditional Directives

  6.4 – Macros

  6.5 – Pragma Directives

  6.6 – Miscellaneous Directives

7 – The Compiler

  7.1 – Installation

  7.2 – Compilation

  7.3 – Execution

8 – The Complete Syntax

9 – Miscellaneous Information

  9.1 – Coding Conventions

    9.1.1 – Naming Conventions

    9.1.2 – Commenting Conventions

    9.1.3 – Miscellaneous Conventions

  9.2 – Credits

  9.3 – License

Clone this wiki locally