Skip to content

Grammar railroad diagram #14

@mingodad

Description

@mingodad

I've just added this project grammar to https://mingodad.github.io/parsertl-playground/playground/ an Yacc/Lex like online interpreter/editor (select Rulekit parser from Examples then click Parse to see a parse tree for the content in Input source) and from there generated an EBNF understood by https://github.com/GuntherRademacher/rr that generates nice navigable railroad diagrams (see bellow with instructions at the top).

I hope it can help document/develop/debug this project grammar.

//
// EBNF to be viewd at
//    (IPV6) https://www.bottlecaps.de/rr/ui
//    (IPV4) https://rr.red-dove.com/ui
//
// Copy and paste this at one of the urls shown above in the 'Edit Grammar' tab
// then click the 'View Diagram' tab.
//

search_condition::=
	  predicate
	| search_condition op_AND search_condition
	| search_condition op_OR search_condition
	| op_NOT search_condition
	| token_LPAREN search_condition token_RPAREN

predicate::=
	  numeric_value_token ineq_operator numeric_value_token
	| array_or_single_value_token eq_operator array_or_single_value_token
	| array_or_single_value_token op_MATCHES token_REGEX
	| array_or_single_value_token
	| array_or_single_value_token op_IN array_value_token

ineq_operator::=
	  op_GT
	| op_GE
	| op_LT
	| op_LE

eq_operator::=
	  op_EQ
	| op_NE
	| op_CONTAINS

array_values::=
	  value_token
	| array_values token_COMMA value_token

array_value_token::=
	  token_LBRACKET array_values token_RBRACKET

array_or_single_value_token::=
	  value_token
	| array_value_token

value_token::=
	  numeric_value_token
	| token_STRING
	| token_BOOL
	| token_IP
	| token_IP_CIDR
	| token_HEX_STRING
	| token_REGEX

numeric_value_token::=
	  token_INT
	| token_FLOAT
	| token_FIELD

//Tokens

// Control
token_LPAREN ::= "("
token_RPAREN ::= ")"
token_LBRACKET ::= "["
token_RBRACKET ::= "]"
token_COMMA ::= ","

// Logical operators
op_NOT ::= ("!"|"not")
op_AND ::= ("&&"|"and")
op_OR ::= ("||"|"or")

// Comparison operators
op_EQ ::= ("=="|"eq")
op_NE ::= ("!="|"ne")
op_LT ::= ("<"|"lt")
op_LE ::= ("<="|"le")
op_GT ::= (">"|"gt")
op_GE ::= (">="|"ge")

op_CONTAINS ::= "contains"
op_MATCHES ::= ("=~"|"matches")
op_IN ::= "in"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions