forked from kin-lang/kin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.bnf
50 lines (30 loc) · 1.61 KB
/
grammar.bnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
; Copyright (c) MURANGWA Pacifique. and affiliates.
; This source code is licensed under the Apache License 2.0 found in the
; LICENSE file in the root directory of this source tree.
; Kin Programming Language's Grammar in BNF (Backus-Naur Form)
program ::= statement*
statement ::= variableDeclaration
| functionDeclaration
| loopStatement
| conditionalStatement
| expressionStatement
| returnStatement
variableDeclaration ::= "reka" | "ntahinduka" identifier ("=" expression)? ";"
functionDeclaration ::= "porogaramu_ntoya" identifier "(" (identifier ("," identifier)*)? ")" "{" statement* "}"
loopStatement ::= "subiramo_niba" "(" expression ")" "{" statement* "}"
conditionalStatement ::= "niba" "(" expression ")" "{" statement* "}" ("nanone_niba" "(" expression ")" "{" statement* "}")? ("niba_byanze" "{" statement* "}")?
expressionStatement ::= expression
returnStatement ::= "tanga" (expression | ";")
expression ::= assignmentExpression
assignmentExpression ::= objectLiteral ("=" assignmentExpression)?
objectLiteral ::= arrayExpression | primaryExpression
arrayExpression ::= "[" (expression ("," expression)*)? "]"
primaryExpression ::= identifier
| numericLiteral
| stringLiteral
| "(" expression ")"
| functionReturn
functionReturn ::= "tanga" (expression | ";")
identifier ::= [a-zA-Z_] [a-zA-Z0-9_]*
numericLiteral ::= [0-9]+ ("." [0-9]+)?
stringLiteral ::= "\"" .* "\""