1. Syntax

1.1. Grammar

1.1.1. Introduction

In this section, the following convention is used:

Element Form Example
Non-Terminal Italics Expression
Verbatim text Monospace if
Terminal Bold literal

1.1.2. Syntax Description

Module \(\rightarrow\) GlobalExpressionsList

GlobalExpressionsList \(\rightarrow\) \(\epsilon\)

GlobalExpressionList \(\rightarrow\) GlobalExpressionList GlobalExpression

GlobalExpression \(\rightarrow\) FuncDef

GlobalExpression \(\rightarrow\) FuncDecl

GlobalExpression \(\rightarrow\) StructDef

FuncDef \(\rightarrow\) def FuncDeclBody Statement

FuncDef \(\rightarrow\) def FuncDeclBody Expression

FuncDecl \(\rightarrow\) decl FuncDeclBody ;

FuncDecl \(\rightarrow\) decl ( literal_string ) FuncDeclBody ;

FuncDeclBody \(\rightarrow\) Identifier ( FuncDeclArgs ) FuncDeclRet

FuncDeclArgs \(\rightarrow\) \(\epsilon\)

FuncDeclArgs \(\rightarrow\) FuncDeclArgsNonEmpty

FuncDeclArgsNonEmpty \(\rightarrow\) FuncDeclArg

FuncDeclArgsNonEmpty \(\rightarrow\) FuncDeclArg , FuncDeclArgsNonEmpty

FuncDeclArg \(\rightarrow\) Identifier : TransientType

FuncDeclRet \(\rightarrow\) \(\epsilon\)

FuncDeclRet \(\rightarrow\) -> TransientType

StructDef \(\rightarrow\) struct Identifier { StructDefBody }

StructDefBody \(\rightarrow\) VariableDefinition StructDefBody

StructDefBody \(\rightarrow\) \(\epsilon\)

Statement \(\rightarrow\) CompoundStatement

Statement \(\rightarrow\) Expression ;

Statement \(\rightarrow\) VariableDefinition ;

Statement \(\rightarrow\) if ( Expression ) Statement

Statement \(\rightarrow\) if ( Expression ) Statement else Statement

Expression \(\rightarrow\) CompoundExpression

Expression \(\rightarrow\) Literal

Expression \(\rightarrow\) Identifier

Expression \(\rightarrow\) Expression ( FuncCallArguments )

Expression \(\rightarrow\) Expression op Expression [1]

Expression \(\rightarrow\) Expression op [1]

Expression \(\rightarrow\) op Expression [1]

Expression \(\rightarrow\) cast_type ! TemplateParam ( Expression )

Expression \(\rightarrow\) Type

Expression \(\rightarrow\) if ( Expression ) CompoundExpression else CompoundExpression [2]

TemplateParam \(\rightarrow\) id

TemplateParam \(\rightarrow\) ( Expression )

Literal \(\rightarrow\) LiteralInt

Literal \(\rightarrow\) LiteralString

Literal \(\rightarrow\) LiteralFP

Literal \(\rightarrow\) LiteralPointer

LiteralString \(\rightarrow\) literal_string

LiteralInt \(\rightarrow\) literal_int

LiteralFP \(\rightarrow\) literal_fp

LiteralPointer \(\rightarrow\) null

CompoundStatement \(\rightarrow\) { StatementList }

CompoundExpression \(\rightarrow\) { StatementList Expression }

StatementList \(\rightarrow\) \(\epsilon\)

StatementList \(\rightarrow\) StatementList Statement

TransientType \(\rightarrow\) Type

TransientType \(\rightarrow\) Type ref

Type \(\rightarrow\) Identifier

Type \(\rightarrow\) Type @

Type \(\rightarrow\) Type [ LiteralInt ]

VariableDefinition \(\rightarrow\) def VariableDeclBody

VariableDefinition \(\rightarrow\) def VariableDeclBody = Expression

VariableDeclBody \(\rightarrow\) Identifier : Type

Identifier \(\rightarrow\) identifier

FuncCallArguments \(\rightarrow\) \(\epsilon\)

FuncCallArguments \(\rightarrow\) FuncCallArgumentsNonEmpty

FuncCallArgumentsNonEmpty \(\rightarrow\) Expression

FuncCallArgumentsNonEmpty \(\rightarrow\) Expression , FuncCallArgumentsNonEmpty

Footnotes

[1](1, 2, 3) For list of actual operators and their precedence, see Operators.
[2]A conditional expression must have an else clause, as it must return a value regardless of the condition’s result.