Skip to content

The Complete Syntax

Sjoerd Vermeulen edited this page Jun 10, 2022 · 6 revisions

8 – The Complete Syntax

This is the complete syntax of Evi represented in BNF:

program			: (func_decl | var_decl)*


declaration		: var_decl
			| statement

func_decl		: "@" "!"? IDENT type "(" type* "..."? ")" (statement | ";")
var_decl		: "%" "!"? IDENT ("," IDENT)* type (expression ("," expression)*)? ";"


statement		: assignment
			| if_stmt
			| loop
			| return
			| block
			| expression ";"

assignment		: "=" IDENT ("[" expression "]")* expression ";"
if_stmt			: "??" "(" expression ")" statement ("::" statement)?
loop			: "!!" "(" declaration? expression ";" declaration? ")" statement
return 			: "~" expression? ";"
block			: "{" declaration* "}"


expression		: ternary

ternary			: logical_or ("?" expression ":" ternary)?
logical_or		: logical_xor ("||" logical_xor)*
logical_or		: logical_and ("^^" logical_and)*
logical_and		: bitwise_or ("&&" bitwise_or)*
bitwise_or		: bitwise_xor ("|" bitwise_xor)*
bitwise_xor		: bitwise_and ("^" bitwise_and)*
bitwise_and		: equality ("&" equality)*
equality		: comparison (("!=" | "==") comparison)*
comparison		: bitwise_shift ((">" | ">=" | "<" | "<=") bitwise_shift)*
bitwise_shift		: term (("<<" | ">>") term)*
term			: factor (("-" | "+") factor)*
factor			: cast (("/" | "*") cast)*
cast			: unary ("->" type)*
unary			: ("*" | "&" | "!" | "-" | "++" | "--") unary | subscript
subscript		: primary ("[" expression "]")*
primary			: NUMBER | CHAR | STRING | "(" expression ")"
			| array | size_of | reference | call

array			: "{" (expression ("," expression)*)? "}"
size_of			: "?" ( "(" type ")" | type )
reference		: "$" (IDENT | INTEGER)
call			: IDENT "(" (expression ("," expression)*)? ")"

type			: ("!")? BASIC_TYPE ("*")*



Next: 9 – Miscellaneous Information

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