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

ANTLR parser for EBNF grammar and get a decomposition tree with results

I’m trying to make a lexical parser to compute all solutions given a EBNF term. For example: Grammar: T::= nil | A.T | (T+T) | (T*T) A::= a | b | c | d | e Operators: * Exclusive OR . Sequence + Parallel Symbols: a b c d e Example…
ccamacho
  • 707
  • 8
  • 22
0
votes
1 answer

ENBF to JavaCC difference between [] and {}

I have the following 2 production rules in EBNF: ::= ' " ' [ ] ' " ' and ::= ' " ' { } ' " ' What is the difference between the two? [] imply 1 or more repetitions and {} imply 0 or more…
user3505334
  • 19
  • 1
  • 4
0
votes
1 answer

Converting BNF to javacc code

I need to convert the following to javacc from EBNF, I have tried various methods however I am getting an error. EBNF: code ::== [\x20 - \x7E] How would this be converted ? Thanks in advance
tas
  • 41
  • 1
  • 6
0
votes
2 answers

parsing XPath expression understanding EBNF production rules

I have a beginners question regarding the W3C specification (EBNF notation) of XPath expressions. The specification can be found at: http://www.w3.org/TR/xpath/. In particular I have a question about understanding the following…
user1362700
  • 155
  • 8
0
votes
1 answer

EBNF : missing the purpose of two production rules

I have this grammar in EBNF for a sub-language with arithmetic & logical expressions, variables assignment and printing. start ::= (print | assign)* print ::= print expr ; assign ::= ID = expr ; expr ::= andExpr (|| andExpr)* andExpr ::=…
slovo
  • 3
  • 1
0
votes
1 answer

How to syntactically ignore a part of an expression in an Antlr BNF?

I would like to use Antlr to parse SQL table DDL statements. But I need only the column identifiers and column types. I do not care about any constraints and I would like to avoid to write the whole syntax especially for CHECK constraints, because…
ceving
  • 21,900
  • 13
  • 104
  • 178
0
votes
2 answers

Splitting by regex or ebnf

I've got a string like: create Person +fname : String, +lname: String, -age:int; Is there any possibility to split it by regex or ebnf? I mean all the things like [a-zA-Z0-9] (things we don't know) will be stored in array? In other words, by using…
Hladeo
  • 577
  • 1
  • 7
  • 16
0
votes
2 answers

Descent recursive parser implementation in C++, based on EBNF Grammar

I have implemented descent recursive parser in C++ that is based on EBNF grammar and its pseudo-code. Here is the code: #include #include #include #include char s[100]; int pos=-1,len; void asignstmt(); void…
sana
  • 410
  • 2
  • 6
  • 24
0
votes
1 answer

How would I normalize the following ANTLR grammar rules to eliminate left recursion?

I'd like to be able to treat: int(int, int) As a function type. How do I normalize this (stripped down) grammar? type : classOrInterfaceType | primitiveType | functionType; functionType : type '(' (type (',' type)*)? ')'; classOrInterfaceType :…
Brent
  • 4,153
  • 4
  • 30
  • 63
0
votes
1 answer

EBNF interpretation of the grammar

How can I interpret this as ENBF grammer? --> = --> A | B | C --> * --> + | + |( ) | I can make parse tree and derivation of any statement using this…
sick
  • 21
  • 3
0
votes
0 answers

In Computer Science(especially in metalanguages using EBNF) , do the symbols -> and <- have specific meaning?

My apologies if this is not in SO's domain - it's a bit high-level/theoretical. I'm studying a custom Language Specification(called ACELandic if you interested). And it is based of of Extended Backus–Naur Form(EBNF ). I see symbols like <-…
Caffeinated
  • 11,982
  • 40
  • 122
  • 216
0
votes
1 answer

How to deal with possible non-terminals?

Let's say I had an EBNF like this: -> {( + | - ) } The {} brackets mean choose zero or more, so how would I know when I have just vs something like + + when I'm reading the line character by…
dtgee
  • 1,272
  • 2
  • 15
  • 30
0
votes
1 answer

EBNF Grammar for list of words separated by a space

I am trying to understand how to use EBNF to define a formal grammar, in particular a sequence of words separated by a space, something like [[ [ [ ...]]] What is the correct way to define a word…
lshepstone
  • 136
  • 9
0
votes
1 answer

EBNF to Bison - Reduce/Reduce error

i have to translate this EBNF to bison: ::= begin [ ( ; )*] end ::= | | | | | when i translate…
1 2 3
23
24