Skip to content

Add EBNF grammar derived from parser.cpp#5

Open
Copilot wants to merge 2 commits intomainfrom
copilot/create-ebnf-grammar
Open

Add EBNF grammar derived from parser.cpp#5
Copilot wants to merge 2 commits intomainfrom
copilot/create-ebnf-grammar

Conversation

Copy link

Copilot AI commented Feb 27, 2026

The repository lacked a formal grammar specification for the Zenith language. This PR adds grammar.ebnf at the repo root, generated directly from src/parser/parser.cpp with rule names corresponding to parser method names.

Changes

  • grammar.ebnf — New file containing the complete EBNF grammar for Zenith, covering all 36 parser methods as named rules:
    • Top-level: parse, parseImport, parseTemplate
    • Declarations: parseVarDecl, parseFunction, parseObject, parseUnion, parseActorDecl, parseConstructor, parseField
    • Expressions: parseExpression, parsePrimary, parseNewExpression, parseFunctionCall, parseMemberAccess, parseArrayAccess, parseArrowFunction, parseArrowFunctionParams
    • Statements: parseStatement, parseBlock, parseIfStmt, parseForStmt, parseWhileStmt, parseDoWhileStmt, parseReturnStmt, parseScopeBlock, parseUnsafeBlock
    • Types & annotations: parseType, parseAnnotation, parseAnnotations, parseTemplateParameters
    • Structural helpers: builtInType, binaryOp, accessModifier, param, structField, terminal definitions

Example rules

parseVarDecl = [ "hoist" ]
               ( ( builtInType | IDENTIFIER ) IDENTIFIER [ "[" parseExpression "]" ]
               | ( "let" | "var" | "dynamic" ) IDENTIFIER [ "[" parseExpression "]" ] [ ":" parseType ] )
               [ "=" parseExpression ] ;

parseFunction = ( "fun" [ parseType ] | parseType ) IDENTIFIER parseParameters
               [ "->" parseType ] parseBlock ;

parseActorDecl = "actor" IDENTIFIER [ ":" IDENTIFIER ]
                "{" { parseMessageHandler | ( parseAnnotations parseObjectPrimary ) } "}" ;

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Gogo64pro Gogo64pro marked this pull request as ready for review February 27, 2026 14:01
Copilot AI review requested due to automatic review settings February 27, 2026 14:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Gogo64pro <96884572+Gogo64pro@users.noreply.github.com>
Copilot AI changed the title [WIP] Add EBNF grammar generation from parser.cpp methods Add EBNF grammar derived from parser.cpp Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants