This document describes the syntax of the Minimacy language. This might help you when your program fails at compile time for syntax reason. ‘*’ means any number, including 0. ‘+’ means any number starting from 1. Red characters are part of the Minimacy syntax. # Types {grammar Type = Native | $($Type$)$ | $[$Type*$]$ | $fun$ Type* $->$ Type | $list$ Type | $fifo$ Type | $hashset$ Type | $hashmap$ Type $->$ Type | $array$ Type | Sum | Struct | Any | Weak | Recursive | Param Sum = Label | Label${$Param+$}$ Struct = Label | Label${$Param+$}$ | Any${$Label$}$ | Weak${$Label$}$ | Any${$Label${$Param+$}}$ | Weak${$Label${$Param+$}}$ Native = Native type: $Int$, $Str$, $Float$, ... Label = User type name Param = Parameter name Any = Type “any”: $a1$, $a2$, $a3$, ... Weak = Weak type: $w1$, $w2$, $w3$, ... Recursive = Recursive type: $r0$, $r1$, $r2$, ... (the number is the level of the recursion) } Recursive types are quite unusual but you may encounter them: - [Int [Int [Int ...]]] is noted [Int r0] - [Int [Str [Int [Str ...]]]] is noted [Int [Str r1]] # Programs {grammar Minimacy = Declaration* Declaration = $fun$ FunctionDef $($ LocalExtList $)$ $=$ Program $;;$ | $var$ GlobalDef $;;$ | $var$ GlobalDef $=$ Program $;;$ | $const$ GlobalDef $;;$ | $const$ GlobalDef $=$ Program $;;$ | $struct$ TypeDef $= [$ FieldList $] ;; $ | $struct$ TypeDef $=$ TypeDef $+ [$ FieldList $] ;; $ | $sum$ TypeDef $=$ Constructs $;;$ | $extend$ TypeDef $with$ Constructs $;;$ | $use$ Package $;;$ | $include$ Package $;;$ | $#ifdef$ Label Minimacy $#endif$ | $#ifdef$ Label Minimacy $#else$ Minimacy $#endif$ | $#ifndef$ Label Minimacy $#endif$ | $#ifndef$ Label Minimacy $#else$ Minimacy $#endif$ | $export$ Export $;;$ | $export$ Export ($,$ Export)* $;;$ Program = Expr | Expr $;$ Program Expr = $:$Type Expr | Arithm | Arithm $::$ Expr | $\\$Special$ Expr Arithm = A1 | A1 $&&$ Arithm | A1 $||$ Arithm A1 = A2 | $!$A1 A2 = A3 | A3 $==$ A3 | A3 $<>$ A3 | A3 $!=$ A3 | A3 $<$ A3 | A3 $>$ A3 | A3 $<=$ A3 | A3 $>=$ A3 | A3 $=.$ A3 | A3 $<.$ A3 | A3 $>.$ A3 | A3 $<=.$ A3 | A3 $>=.$ A3 A3 = A4 | A4 $+$ A3 | A4 $-$ A3 | A4 $+.$ A3 | A4 $-.$ A3 A4 = A5 | A5 $*$ A4 | A5 $/$ A4 | A5 $%$ A4 | A5 $*.$ A4 | A5 $/.$ A4 | A5 $**$ A4 | A5 $**.$ A4 A5 = A6 | A6 $&$ A5 | A6 $|$ A5 | A6 $^$ A5 | A6 $<<$ A5 | A6 $>>$ A5 A6 = Term | $-$ A6 | $~$ A6 | $-.$ A6 | $-$ Integer | $-$ Float | Float Term = $($ Program $)$ | $($ Program $;)$ | Integer | $'$Char$'$ | $nil$ | String | $[$ TypeName $]$ | $[$ NameOfField $=$ Expr $]$ | $[$ NameOfField $=$ Expr ($,$ NameOfField $=$ Expr)* $]$ | $[$ ExprList $]$ | ${$ ExprList $}$ | Ref | $set$ Ref $=$ Expr | TypeName $<$ Expr | TypeName $<$ TypeName Expr | Function $($ ExprList $)$ | MonoFunction Expr | $#$ Function | $lambda$ $($ LocalExtList $)$ $=$ Program | $let$ Program $->$ LocalExt $in$ Expr | $if$ Expr $then$ Expr ($elif$ Expr $then$ Expr)* $else$ Expr | $if$ Expr $then$ Expr ($elif$ Expr $then$ Expr)* | $while$ Expr $do$ Expr | $repeat$ Expr $until$ Expr | $for$ LocalExt $=$ Expr $;$ Expr $;$ Expr $do$ Expr | $for$ Local $=$ Expr $;$ Expr $do$ Expr | $for$ LocalExt $in$ Expr $do$ Expr | $for$ LocalExt $of$ Expr $do$ Expr | $call$ Expr $($ ExprList $)$ | ConsName Expr* | $match$ Expr $with$ Case | $break$ Expr | $continue$ Expr | $return$ Expr | $try$ Expr | $try$ Expr $else$ Expr | $abort$ ExprList = empty | Expr | Expr ($,$ Expr)* LocalExtList = empty | LocalExt | LocalExt ($,$ LocalExt)* LocalExt = Local | Local $:$Type | $_$ | LocalExt$::$ LocalExt | $[$ LocalExtList $]$ | $($LocalExt$)$ FieldList = Field ($,$ Field)* Field = FieldName | FieldName $:$Type Constructs = Construct | Construct$,$ Constructs Construct = ConsName ConsArg* ConsArg = ConsArgName | ConsArgName $:$Type | $:$Type | $_$ Case = Case' | Case' $,$ Case | $_ ->$ Expr Case' = Expr $->$ Expr | ConsName LocalExt* $->$ Expr | TypeName Local $->$ Expr Ref = Label | Ref $.$ FieldName | Ref $[$ Expr $]$ Export = Label | Label $($ LabelList $)$ LabelList = empty | Label | Label ($,$ Label)* Label = Global | Local GlobalDef = Global | Global$:$Type FunctionDef = Function | Function$:$Type Function = name of a function (lowercase first letter) Local = name of a local variable Global = name of a global variable or constant (uppercase first letter) TypeDef = TypeName | TypeName $ {$ Labels+ $}$ Type = type (see Appendix “Type grammar”) Special = special mode: $atomic$, $float$, $bigNum$, $integer$, $mod$, $modBarrett$ MonoFunction = special functions with one argument: $echo$, $echoLn$, $echoTime$, $dump$, $hexDump$, $hexDumpBytes$, $arrayDump$, $echoHexLn$ TypeName = type name (uppercase first letter) FieldName = field name ConsName = constructor name (lowercase first letter) ConsArgName = constructor argument name Package = string | PackageName PackageName = Name | Name $.$ PackageName Integer = integer: decimal, hexadecimal Char = character String = binary string inside double-quotes Float = floating number Comments = lines starting with $//$ | $/*$ ... $*/$ }