Skip to content

Grammar railroad diagram #520

Description

@mingodad

With small changes to the lang we can have a nice navigable railroad diagram to enhance the documentation (see intructions bellow at the top):

//From: https://github.com/cel-expr/cel-spec/blob/9768251bef69c35d98b9940f453f1f583c55e013/doc/langdef.md
//
// EBNF to be viewd at
//	https://www.bottlecaps.de/rr/ui
//
// Copy and paste this at one url shown above in the 'Edit Grammar' tab
// then click the 'View Diagram' tab.
//

Expr           ::= ConditionalOr ("?" ConditionalOr ":" Expr)?
ConditionalOr  ::= (ConditionalOr "||")? ConditionalAnd
ConditionalAnd ::= (ConditionalAnd "&&")? Relation
Relation       ::= (Relation Relop)? Addition
Relop          ::= "<" | "<=" | ">=" | ">" | "==" | "!=" | "in"
Addition       ::= (Addition ("+" | "-"))? Multiplication
Multiplication ::= (Multiplication ("*" | "/" | "%"))? Unary
Unary          ::= Member
               | "!"+ Member
               | "-"+ Member

Member         ::= Primary
               | Member "." SELECTOR ("(" ExprList? ")")?
               | Member "[" Expr "]"

Primary        ::= "."? IDENT ("(" ExprList? ")")?
               | "(" Expr ")"
               | "[" ExprList? ","? "]"
               | "{" MapInits? ","? "}"
               | "."? SELECTOR ( "." SELECTOR )* "{" FieldInits? ","? "}"
               | LITERAL

ExprList       ::= Expr ("," Expr)*
FieldInits     ::= SELECTOR ":" Expr ("," SELECTOR ":" Expr)*
MapInits       ::= Expr ":" Expr ("," Expr ":" Expr)*

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions