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
9
votes
1 answer

Convert BNF grammar to pyparsing

How can I describe a grammar using regex (or pyparsing is better?) for a script languge presented below (Backus–Naur Form): := | := [* ] := "{" "}" | ; :=…
Max Tkachenko
  • 792
  • 1
  • 12
  • 30
9
votes
1 answer

AS3 Grammar: Most accurate

I'm looking for an accurate AS3 grammar (format in not an issue, but I presume ANTLR will feature the most) to use for a practice grammar I'm making. What is the most accurate grammar available for AS3?
BefittingTheorem
  • 10,459
  • 15
  • 69
  • 96
9
votes
4 answers

Is there a BNF mode for Emacs?

I have to edit lots of grammar files in .bnf format. Is there a mode for this in Emacs? I've looked at CEDET's semantic package, and it seems that it USED to have a bnf-mode, but not any more. This snippet is googlable, but semantic-bnf-mode doesn't…
jmmcd
  • 731
  • 6
  • 15
9
votes
5 answers

Parser-generator that outputs C# given a BNF grammar?

I'm looking for a tool that will be able to build a parser (in C#) if I give it a BNF grammar (eg. http://savage.net.au/SQL/sql-2003-2.bnf) Does such a generator exist?
ilitirit
  • 16,016
  • 18
  • 72
  • 111
9
votes
2 answers

BNF for comma separated sequence?

Can't come up with a BNF grammar for the sequence of characters (possibly empty), separated by comma, but not starting or ending with a comma, So this is OK: <--- Empty sequence is ok! A A,B A,B,C This is NOT ok: A, ,A A,,B AB The empty case…
Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
8
votes
1 answer

Produce Delphi Code that will Parse a file with a given BNF format

Is there parser code or a parser component for Delphi or a program that will accept BNF (Backus-Naur Form) notation as input and produce Delphi (or pascal) code to do the parsing? The reason for this is that I am going to be attempting to perfectly…
lkessler
  • 19,819
  • 36
  • 132
  • 203
8
votes
1 answer

How to send a BREW request for a coffee with cream and a shot of vanilla to a HTCPCP server

I am trying to send a BREW request to a server implementing the Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0, defined in RFC 2324), which is a protocol built on top of HTTP, using cURL. I would like to BREW a coffee with Cream and a shot of…
ajq88
  • 305
  • 1
  • 14
8
votes
2 answers

Python lexical analysis - logical line & compound statements

So I understand that: The end of a logical line is represented by the token NEWLINE This means the way Python's grammar is defined the only way to end a logical line is with a \n token. The same goes for physical lines (rather an EOL, which is the…
Marius Mucenicu
  • 1,685
  • 2
  • 16
  • 25
8
votes
1 answer

How to represent vertical alignment of syntax of code using BNF, EBNF or etc.?

How to say that (in BNF, EBNF, etc) any two or more letters are placed in the same vertical alignment e.g In python 2.x, we have what we call indentation. def hello(): print "hello," print "world" hello() Note letter p (second line) is…
fronthem
  • 4,011
  • 8
  • 34
  • 55
8
votes
2 answers

Erlang syntax - Building an Intellij IDEA language support plugin for Erlang

I'm looking to create an Intellij IDEA language support plugin for Erlang. The first and biggest problem I've had is in making the JFlex Erlang syntax definition. Does anyone know where can I get the EBNF or BNF for Erlang?
unorsk
  • 9,371
  • 10
  • 36
  • 42
8
votes
1 answer

BNF Rule Syntax Highlighting for Custom Language

I'm trying to develop a custom language plugin for IntelliJ using the Grammar-Kit plugin. I am easily able to provide syntax highlighting for tokens defined, but I cannot figure out how to highlight at the element or token-parent level. Here's a…
pyrospade
  • 7,870
  • 4
  • 36
  • 52
8
votes
2 answers

What RFC defines arrays transmitted over HTTP?

What RFC defines the passing arrays over HTTP? Most web application platforms allow you to supply an array of arguments over GET or POST. The following URL is an example: http://localhost/?var[1]=one&var[2]=two&var[3]=three RFC1738 defines URLs, …
rook
  • 66,304
  • 38
  • 162
  • 239
8
votes
2 answers

How to convert BNF to EBNF

How can I convert this BNF to EBNF? ::= var ; ::= {;} ::= {,} : ::= {} ::= | | _
Deshi Basara
  • 81
  • 1
  • 1
  • 3
8
votes
1 answer

C++ BNF grammar with parsing/matching examples

I'm developing a C++ parser (for an IDE), so now trying to understand C++ grammar in details. While I've found an excellent grammar source at http://www.nongnu.org/hcb/, I'm having trouble understanding some parts of it - and, especially, which…
intelfx
  • 2,386
  • 1
  • 19
  • 32
7
votes
1 answer

BNF Grammar Ambiguity

I was recently thinking of the following BNF A -> x | yA | yAzA where x,y,z are terminals. I'm pretty sure this grammar is ambiguous, but how would one make it unambiguous?
Mark Kennedy
  • 1,751
  • 6
  • 30
  • 53
1 2
3
37 38