# formal BNF/EBNF grammar specification for Verse?

**URL:** <https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217>\
**Category:** Programming & Scripting\
**Tags:** fortnite-creative, unreal-editor-for-fortnite, question, fortnite\
**Created:** [June 9, 2024, 11:26am UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217 "2024-06-09T11:26:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![enealefons](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/enealefons/32/945520_2.png) [@enealefons](https://forums.unrealengine.com/u/enealefons)\
**Post date:** [June 9, 2024, 11:26am UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217/1 "2024-06-09T11:26:07Z")

</div>

Dearest Verse wizards!  
The docs are great for getting started, but I’m really looking for the formal BNF/EBNF grammar spec for Verse.

Is it available anywhere, also in a work in progress form?

Why do I want it?

**Clarity:** A detailed grammar helps us nail down syntax rules.

- **Tooling** : We can build cool stuff like syntax highlighters, parsers and more, making Verse coding smoother.

- **Learning** : It’s a huge help for anyone teaching or learning Verse, making the language mechanics clearer.

- **Community** : With a solid grammar, we can contribute more—whether it’s tutorials, resources, or code improvements.

So, any chance you could share or point us to the formal grammar spec for Verse? It’d be a massive help for all of us pushing the limits with UEFN and Verse.

THANK YOU!

---

<div class="post-metadata">

**Author:** ![t.tutiya](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/t.tutiya/32/924637_2.png) [@t.tutiya](https://forums.unrealengine.com/u/t.tutiya)\
**Post date:** [June 10, 2024, 4:27am UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217/2 "2024-06-10T04:27:52Z")

</div>

Hi.  
As far as I know, This is the only article that mentions BNF

> [@Ask Epic Anything: Programming & Scripting | May 24th, 2023 at 12:30PM EST](https://forums.unrealengine.com/t/ask-epic-anything-programming-scripting-may-24th-2023-at-12-30pm-est/1168968/89):
>
> Yes there is a Verse BNF - we probably just need to clean it up and remove the future plans from what is currently present before we can put it online in the Verse documentation. Technically yes - they are separate types in Verse. One of the hints is that true and false are both lowercase like other Verse type name conventions. They aren’t indicated that way in the docs currently though the typing in Verse is quite sophisticated and as this becomes more feature complete the docs will better r…

---

<div class="post-metadata">

**Author:** ![enealefons](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/enealefons/32/945520_2.png) [@enealefons](https://forums.unrealengine.com/u/enealefons)\
**Post date:** [June 10, 2024, 12:02pm UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217/3 "2024-06-10T12:02:03Z")

</div>

Thank you for the link!

Looks like more months of guesswork and brute force debugging are ahead 😃 may we have the power and resilience to push through - hahaha

---

<div class="post-metadata">

**Author:** ![enealefons](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/enealefons/32/945520_2.png) [@enealefons](https://forums.unrealengine.com/u/enealefons)\
**Post date:** [June 11, 2024, 3:30am UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217/4 "2024-06-11T03:30:05Z")

</div>

> [@enealefons](#):
>
> formal BNF/EBNF grammar spec for Verse

Update: since I seem to have little respect for my free time, I decided to go about it anyway while we wait for an official and complete one:

here’s super preliminary attempt: sharing it here in case it helps :

```auto
(* Enea's Unofficial EBNF Grammar for Verse - v30*)

(* Terminals *)
identifier = letter, { letter | digit | "_" } ;
integer = digit, { digit } ;
float = integer, ".", integer ;
string = "\"", { character }, "\"" ;

(* Non-Terminals *)
program = { import_statement | class_definition | function_definition | variable_declaration } ;

import_statement = "using", "{", identifier, { ",", identifier }, "}" ;

class_definition = identifier, ":=", "class", ["<", class_specifier, ">"], ":", class_body ;
class_specifier = "public" | "private" | "protected" | "internal" | "concrete" | "final" | "persistable" | "unique" ;
class_body = { variable_declaration | function_definition | constructor_definition | block_expression } ;

function_definition = identifier, "(", [parameter_list], ")", ["<", function_specifier, ">"], ":", type, "=", function_body ;
function_specifier = "suspends" | "transacts" | "decides" | "converges" | "override" ;
parameter_list = parameter, { ",", parameter } ;
parameter = identifier, ":", type ;
type = "void" | "int" | "float" | "string" | "bool" | "array", "<", type, ">" | "map", "<", type, ",", type, ">" | identifier ;

variable_declaration = ["var"], identifier, ":", type, ["=", expression] ;

constructor_definition = identifier, "(", [parameter_list], "):", class_body ;

block_expression = "block", ":", { statement } ;

statement = variable_declaration | assignment | function_call | if_statement | loop_statement | defer_statement | await_statement ;

assignment = identifier, "=", expression ;
function_call = identifier, "(", [argument_list], ")" ;
argument_list = expression, { ",", expression } ;

if_statement = "if", "(", expression, ")", block_expression ;
loop_statement = "loop", ":", block_expression ;
defer_statement = "defer", ":", block_expression ;
await_statement = "await", "(", expression, ")" ;

expression = literal | identifier | function_call | binary_expression | unary_expression ;
literal = integer | float | string | "true" | "false" ;
binary_expression = expression, binary_operator, expression ;
unary_expression = unary_operator, expression ;
binary_operator = "+" | "-" | "*" | "/" | "=" | "<>" | "<" | ">" | "<=" | ">=" ;
unary_operator = "-" | "not" ;

(* Comments *)
comment = "#", { character } ;

```

---

<div class="post-metadata">

**Author:** ![sonictke](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sonictke/32/924209_2.png) [@sonictke](https://forums.unrealengine.com/u/sonictke)\
**Post date:** [June 14, 2024, 3:25am UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217/5 "2024-06-14T03:25:28Z")

</div>

Unfortunately, Conan’s answer is still the only one I can confirm here: we have a formal BNF for Verse, but it is not currently publicly available; the only thing that you can refer to is the VS Code extension for the current syntax highlighting. We definitely want this to be made available and we are slowly getting there.

---

<div class="post-metadata">

**Author:** ![enealefons](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/enealefons/32/945520_2.png) [@enealefons](https://forums.unrealengine.com/u/enealefons)\
**Post date:** [June 17, 2024, 11:14am UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217/6 "2024-06-17T11:14:32Z")

</div>

FYI, since I really need it, based on a couple of feedbacks I tried to push it a tad further, sharing it here in case it can be helpful to others!

Looking forward to the offical one!

```auto
# Enea's Very Unofficial EBNF Grammar for Verse - v33

# Basic Symbols
letter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" |
         "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;

# Identifiers
identifier = letter , { letter | digit | "_" } ;

# Types
type = "int" | "float" | "string" | "bool" | "void" | "array" "[" type "]" | "map" "[" type "," type "]" | "option" "{" type "}" | identifier ;

# Literals
integer_literal = digit , { digit } ;
float_literal = digit , { digit } , "." , digit , { digit } ;
string_literal = '"' , { character } , '"' ;
boolean_literal = "true" | "false" ;

# Expressions
expression = or_expression ;
or_expression = and_expression , { "or" , and_expression } ;
and_expression = equality_expression , { "and" , equality_expression } ;
equality_expression = relational_expression , { ( "=" | "<>" ) , relational_expression } ;
relational_expression = additive_expression , { ( "<" | ">" | "<=" | ">=" ) , additive_expression } ;
additive_expression = multiplicative_expression , { ( "+" | "-" ) , multiplicative_expression } ;
multiplicative_expression = unary_expression , { ( "*" | "/" | "%" ) , unary_expression } ;
unary_expression = [( "-" | "not" )] , primary_expression ;
primary_expression = identifier | integer_literal | float_literal | string_literal | boolean_literal | "(" , expression , ")" ;

# Statements
statement = block | assignment | if_statement | while_statement | for_statement | return_statement | expression_statement ;
block = "{" , { statement } , "}" ;
assignment = identifier , ":=" , expression , ";" ;
if_statement = "if" , "(" , expression , ")" , statement , ["else" , statement] ;
while_statement = "while" , "(" , expression , ")" , statement ;
for_statement = "for" , "(" , [assignment] , [expression] , ";" , [assignment] , ")" , statement ;
return_statement = "return" , [expression] , ";" ;
expression_statement = expression , ";" ;

# Declarations
declaration = class_declaration | function_declaration | variable_declaration ;
class_declaration = "class" , identifier , ["(" , identifier , ")"] , "{" , { class_member } , "}" ;
class_member = variable_declaration | function_declaration ;
function_declaration = identifier , "(" , [parameter_list] , ")" , ["<" , "suspends" , ">"] , ":" , type , "=" , block ;
parameter_list = parameter , { "," , parameter } ;
parameter = identifier , ":" , type ;
variable_declaration = "var" , identifier , ":" , type , [":=" , expression] , ";" ;

# Programs
program = { declaration } ;

# Top-level rule
verse_program = { import_statement } , program ;
import_statement = "using" , "{" , string_literal , "}" , ";" ;

```

---

<div class="post-metadata">

**Author:** ![sonictke](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sonictke/32/924209_2.png) [@sonictke](https://forums.unrealengine.com/u/sonictke)\
**Post date:** [August 16, 2024, 9:08pm UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217/7 "2024-08-16T21:08:54Z")

</div>

Hi @enealefons :

While a little bit obscured, the Verse parser is now technically part of the UnrealEngine GitHub repository, which parses the Verse EBNF. You can see the various rules for the EBNF grammar within the comments in the file.

Refer to: [https://github.com/EpicGames/UnrealEngine/blob/ue5-main/Engine/Source/Runtime/VerseCompiler/Public/uLang/Parser/VerseGrammar.h](https://github.com/EpicGames/UnrealEngine/blob/ue5-main/Engine/Source/Runtime/VerseCompiler/Public/uLang/Parser/VerseGrammar.h)

---

<div class="post-metadata">

**Author:** ![enealefons](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/enealefons/32/945520_2.png) [@enealefons](https://forums.unrealengine.com/u/enealefons)\
**Post date:** [August 20, 2024, 10:11am UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217/8 "2024-08-20T10:11:44Z")

</div>

! ! ! ! ! ! A M A Z I N G ! ! ! ! ! !  
thank you SO MUCH @sonictke , this really helps! BUT… I get error 404 😃  
I’ll keep on looking

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/6/0/3607f9c28eda9d328d71d21c25275266dd25f92c.jpeg)

---

<div class="post-metadata">

**Author:** ![Mineblo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mineblo/32/1203575_2.png) [@Mineblo](https://forums.unrealengine.com/u/Mineblo)\
**Post date:** [August 20, 2024, 3:40pm UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217/9 "2024-08-20T15:40:20Z")

</div>

@enealefons the page works fine for me

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/9/9b95422a3fd7e9a91072f733e61d9b5641a61cd5.png)  
I believe you need to follow the instructions here [https://www.unrealengine.com/en-US/ue-on-github](https://www.unrealengine.com/en-US/ue-on-github) to be added

---

<div class="post-metadata">

**Author:** ![enealefons](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/enealefons/32/945520_2.png) [@enealefons](https://forums.unrealengine.com/u/enealefons)\
**Post date:** [August 22, 2024, 9:37am UTC](https://forums.unrealengine.com/t/formal-bnf-ebnf-grammar-specification-for-verse/1896217/10 "2024-08-22T09:37:33Z")

</div>

thank you @Mineblo , I reconnected my account to Github and now I’m in!  
@sonictke thank you so much for the tip, I’m trying to reverse engineer in order to extract the rules I was missing… interesting task 😃
