Questions tagged [bnf]

BNF stands for Backus-Naur Form, or Backus Normal Form. It is a form of notation for context-free grammars and is often used for (but is not restricted to) the description of the syntax of programming languages. In addition to programming languages, it is also used to describe communication protocols and document formats.

A BNF specification is a set of derivation rules, written as

<symbol> ::= __expression__

where <symbol> is a nonterminal, and the __expression__ consists of one or more sequences of symbols; more sequences are separated by | indicating a choice, the whole being a possible substitution for the symbol on the left. Symbols that never appear on a left side are terminals. On the other hand, symbols that appear on a left side are non-terminals and are always enclosed between the pair <>. The ::= means that the symbol on the left must be replaced with the expression on the right.

561 questions
0
votes
0 answers

equivalent to go gocc to generate a shift reduce parser from a bnf grammar file in Java

I generated a shift reduce parser using a bnf grammar file using gocc (https://code.google.com/p/gocc/) i would like to generate almost equivalent classes for my parser and lexer in java using the same bnf file. Any tool you know of that does this…
Mouna Cheikhna
  • 38,870
  • 10
  • 48
  • 69
0
votes
1 answer

What BNF Variant is This?

I was looking into making a Bison-based parser using some BNF files I found on Github. My issue, however, is that I cannot seem to determine what variation of BNF the files are using. Here is a link to a folder containing samples of the BNF…
belph
  • 362
  • 2
  • 10
0
votes
1 answer

Is This Valid BNF Grammar?

I just wrote up some BNF and I'm a noobie at it, so I wanted to check with you guys if this is valid grammar, and if the input supplied can run? BNF: -> + + | + - | - + | -
nward17
  • 31
  • 3
0
votes
1 answer

BNF Parse Tree Inquiry

I am currently enrolled in a computer architecture class and I'm trying to do one of the homework assignments. The assignment is on BNF and even after having the lecture, reading the slides, and looking online, I'm still stumped. Here is my…
nward17
  • 31
  • 3
0
votes
1 answer

URL BNF search part does not make sense

While implementing a Java regular expression for URL based on the URL BNF published by W3C, I've failed to understand the search part. As quoted: httpaddress h t t p : / / hostport [ / path ] [ ? search ] …
Asaf Mesika
  • 1,643
  • 4
  • 20
  • 33
0
votes
0 answers

(L)BNF grammar for GAMS

Is there a place I can find Backus–Naur Form (BNF) grammar for General Algebraic Modeling System (GAMS)? I have searched the web but have turned up empty handed. I figure it must exist somewhere.
ebergq
  • 11
  • 1
  • 1
0
votes
0 answers

BNF to standard EBNF

I am converting BNF dialect 2 to standard EBNF and making the grammar as simple as possible from this problem below. -> | ; -> | ; -> | ; here is my attempt that I followed along page…
Noobie
  • 65
  • 5
0
votes
1 answer

EBNF rule into BNF

Hi I am having a lot of trouble with this problem and I came across a lot of sites but found this post How to convert BNF to EBNF to be very helpful but I just don't know where to start with this example. -->…
Noobie
  • 65
  • 5
0
votes
1 answer

How should "or" be treated in a BNF production rule?

I'm looking at the BNF grammar for SVG path data, and one of the derivation rules is: digit-sequence ::= digit | digit digit-sequence Is there a sematic difference beween this rule and: digit-sequence ::= digit digit-sequence | digit Exactly what…
Andreas Brinck
  • 51,293
  • 14
  • 84
  • 114
0
votes
1 answer

Parsing string text to num in spanish grammar

I need to write a Python programm to convert spanish numbers in string text into digit numbers: Input: 'Ciento Veinticuatro Mil Ochocientos Treinta y Cinco' Output desired: 124835 I've wrote some code, but I've realized that I'm reinventing the…
Trimax
  • 2,413
  • 7
  • 35
  • 59
0
votes
1 answer

Modifying the BNF grammar to allow new binary operation

I am going through the concept BNF. I got to know how to draw the syntax trees and finding the ambiguous grammar. I came to know that the grammar can be modified and the new binary operation(&) an be added to the existing grammar with implied…
Deepak
  • 7
  • 4
0
votes
1 answer

BNF grammar for the set of rules

I have a problem (a) Give a grammar using BNF rules to construct a program in the language "witless". A witless program must follow the rules: The program must start and end with the word 'endstart' . There are three types of statements in the…
0
votes
2 answers

What does mean \? escape in C grammar?

I was reading this and found the escape \?. What does means exactly this escape? the literal ? inside a string(I still can't see a reason) or is this a BNF grammar rule which I don't know about?
Jack
  • 16,276
  • 55
  • 159
  • 284
0
votes
1 answer

Grammar conflict - Reduce Reduce Conflict Gold sparser

Im get a conflict reduce-reduce in the below code , ive tried almost all i ideas i came up with to solving it heres the report of the problem, this is a BNF->Gold parser conversion any ideas to solve it i would aprreciate it ::=
0
votes
2 answers

What's the BNF of doctrine for?

It looks like a big mess,how does it work as reference? http://www.doctrine-project.org/documentation/manual/1_1/en/dql-doctrine-query-language%3Abnf
user198729
  • 61,774
  • 108
  • 250
  • 348