From 5409e79d4e2917e8daa4d7d218b0cf25686ffe98 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Fri, 6 Jun 2025 00:21:08 +0200 Subject: Feature: Support declaring type aliases --- grammar.ebnf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'grammar.ebnf') diff --git a/grammar.ebnf b/grammar.ebnf index cecc65e..48667b2 100644 --- a/grammar.ebnf +++ b/grammar.ebnf @@ -34,7 +34,7 @@ UnaryExpression ::= ("!" | "-" | "*") UnaryExpression | PostfixExpression PostfixExpression ::= PrimaryExpression (FieldAccess | FunctionCallStatement | CastStatement | SizeOfStatement)* -PrimaryExpression ::= NULL | NUMBER | BOOLEAN | CHAR | STRING | IDENTIFIER | FunctionDefinition | StructDefinition | StructInstantiation | FieldAccess | LPAREN Expression RPAREN +PrimaryExpression ::= NULL | NUMBER | BOOLEAN | CHAR | STRING | IDENTIFIER | FunctionDefinition | TypeDefinition | StructDefinition | StructInstantiation | FieldAccess | LPAREN Expression RPAREN FunctionDefinition ::= LPAREN FunctionParameters? RPAREN ARROW IDENTIFIER LBRACE Statement* ReturnStatement SEMICOLON RBRACE @@ -46,6 +46,8 @@ FunctionType ::= LPAREN (Type ("," Type)*)? RPAREN ARROW Type ParameterTypes ::= Type ("," Type)* +TypeDefinition ::= "newtype" Type + StructDefinition ::= "struct" LBRACE (StructField ("," StructField)*)? RBRACE StructField ::= IDENTIFIER ":" Type -- cgit 1.4.1