Questions tagged [ebnf]

EBNF stands for Extended Backus-Naur Form, or Extended Backus Normal Form. It is an extension to BNF and is used to describe the syntax of context-free grammars, such as programming languages, document formats, or communication protocols. It improves over BNF by providing operators to express optional, zero or more, and one or more occurrences of a term. This makes EBNF much more expressive and concise compared to BNF.

EBNF is standardized format for documenting syntax. It includes an extension mechanism for defining a two-level grammar that can produce an infinite number of production rules.

References

354 questions
0
votes
1 answer

How do I convert a PCRE to EBNF?

I'm writing a spec thingamajig and I don't know EBNF. I have the following PCRE: ^(?:\$(?:\$|{\d+})|[^$])*$ Where, in the input: $$ is an escaped $. ${num} is an argument number. Everything else (that is not a $) is a literal. A $ not followed by…
SoniEx2
  • 1,864
  • 3
  • 27
  • 40
0
votes
1 answer

Converting BNF grammar rules into actual C++ functions/code

I'm trying to create a recursive descent parser. So far I have all the foundation set, I just need to properly implement a few functions to enforce the grammar. I thought everything was right, it looks it, but I guess my Aop, Expr, or Term function…
Abe
  • 229
  • 3
  • 7
0
votes
1 answer

Solution to a joke related to EBNF

What do you think, what is the solution to the following problem related to EBNF? The following message was seen on a bumper sticker: Stinks Syntax. What is the joke? So far this I got to my mind: r1 ::= in | yn r2 ::= ks | x Stinks Syntax ::= St r1…
Vlad
  • 2,739
  • 7
  • 49
  • 100
0
votes
1 answer

Write EBNF form for a year/month/day

I want to find solution to the next problem, but I need to write EBNF of time in two formats, year-month-day and month-day-year to see the differences: Identify one advantage of writing dates as a structured-integer in the form: year, month, day…
Vlad
  • 2,739
  • 7
  • 49
  • 100
0
votes
2 answers

PEG parsing match at least one preserving order

Given the PEG rule: rule = element1:'abc' element2:'def' element3:'ghi' ; How do I rewrite this such that it matches at least one of the elements but possibly all while enforcing their order? I.e. I would like to match all of the following…
ARF
  • 7,420
  • 8
  • 45
  • 72
0
votes
1 answer

Grako - How to do error handling?

How do I do error handling with Grako? EBNF (MyGrammar.ebnf): pattern = { tag | function }* ; tag = tag:( "%" name:id "%" ); function = function:("$" name:id "()" ); id = ?/([^\\%$,()=])+/? ; I'm generating the parser with python -m…
Sebastian
  • 3
  • 2
0
votes
1 answer

Translating Python's formal language into Rail Diagrams

I am currently trying to translate Python's formal grammar (https://docs.python.org/3/reference/grammar.html) into Rail Diagrams. The website we are using http://www.bottlecaps.de/rr/ui is very helpful for most of it and we have changed many things…
Toombzie
  • 5
  • 1
0
votes
1 answer

Jison parser stops after first rule

I've got a simple file format that I want to parse with the jison parser generator. This file can consist of multiple expressions in arbitrary order and quantity. Here is the jison file for the parser: /* lexical grammar */ %lex %% \s+ …
tomvodi
  • 5,577
  • 2
  • 27
  • 38
0
votes
1 answer

Is EBNF considered as a Programming Language

I am confused wheter EBNF can be considered as a Programming language which is turing complete?
0
votes
1 answer

EBNF Syntax for imaginary language

In school we have been studying metalanguages, in particular, railroad diagrams and EBNF. I received a question where an imaginary programming language (winston) was described in EBNF. Here it is: Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 LCase…
0
votes
1 answer

These BNF's codes are difficult for me to understand

I read a paper about BNF, and there are some codes I don't understand. terminal ::= """value":"value""" value ::= ["$"]letters_and_or_digits I don't understand the """value":"value"""means. And the letters_and_digits has no more definition.…
Klloshar
  • 1
  • 1
0
votes
0 answers

Why EBNF can't start with {...}

Today, I saw a video on the Youtube. And there are something I couldn't understand. It says EBNF can't start with {...}. Which means this expression: expr => {term + } term; is WRONG. Why?
Klloshar
  • 1
  • 1
0
votes
2 answers

Exponent operator does not work when no space added? Whats wrong with my grammar

I am trying to write an expression evaluator in which I am trying to add underscore _ as a reserve word which would denote a certain constant value. Here is my grammar, it successfully parses 5 ^ _ but it fails to parse _^ 5 (without space). It only…
fahadash
  • 3,133
  • 1
  • 30
  • 59
0
votes
1 answer

How does a parser for the infix notation detect the missing multiplication sign?

I am writing a parser that parses mathematical expressions based on a syntax diagram very similar to this one. I have not found a way to handle a missing multiplication sign (for example in 3(x+y)). Where in the syntax diagram do I have to handle…
HerpDerpington
  • 3,751
  • 4
  • 27
  • 43
0
votes
1 answer

Xtext grammar variable definition/reference

A [any type]Realisation grammar rule initialization should be a value or a reference to a predefined variable. For Integer it looks similar like what you know from java: public int i = 3; Why does the following grammar throw an exception? Integer…
user972851
  • 191
  • 1
  • 17