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
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

Parsing wikimedia markup - are EBNF-based parsers poorly suited?

I am attempting to parse (in Java) Wikimedia markup as found on Wikipedia. There are a number of existing packages out there for this task, but I have not found any to fit my needs particularly well. The best package I have worked with is the…
toluju
  • 4,097
  • 2
  • 23
  • 27
8
votes
1 answer

Generate EBNF from ANTLR

Anybody know of a tool, that generates EBNF from ANTLR? ANTLR is already close to EBNF, but for documentation purpose I would like to have a clean EBNF description (without the Code in between). With antlrworks and this its already nice to get the…
flolo
  • 15,148
  • 4
  • 32
  • 57
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
1 answer

Describing operator precedence using EBNF

I have written tokenizer and expression evaluator for a preprocessor language that I plan to use in my later projects. I started thinking that maybe I should describe the language with EBNF (Extended Backus–Naur Form) to keep the syntax more…
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
2 answers

How to convert BNF to EBNF

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

What is the meaning of `~` in python grammar

I was going through the python grammer specification and find the following statement, for_stmt: | 'for' star_targets 'in' ~ star_expressions ':' [TYPE_COMMENT] block [else_block] What does ~ means in this grammar rule?. The other symbols used…
Abdul Niyas P M
  • 18,035
  • 2
  • 25
  • 46
7
votes
1 answer

Reading and Understanding Common Lisp (HyperSpec) Documentation

In trying to gather a deeper familiarity with Common Lisp's tools, I found myself struggling when reading the documentation. Namely, it is difficult to comprehend what the usage of the macro in question would look like. For instance, consider…
MadPhysicist
  • 5,401
  • 11
  • 42
  • 107
7
votes
1 answer

Difficulties implementing DSL in Prolog from EBNF using DCG

I'm working on implementation of the Google Protobuf compiler for proto files in Prolog for generating Prolog programs. Prolog is SWI-Prolog. I'm translating EBNF definitions into DCG and ran across a few problems: I have to deal with [ ... ] and {…
Anton Danilov
  • 1,246
  • 11
  • 26
7
votes
5 answers

Grammars, Scala Parsing Combinators and Orderless Sets

I'm writing an application that will take in various "command" strings. I've been looking at the Scala combinator library to tokenize the commands. I find in a lot of cases I want to say: "These tokens are an orderless set, and so they can appear in…
BefittingTheorem
  • 10,459
  • 15
  • 69
  • 96
7
votes
2 answers

BNF grammar for left-associative operators

I have the following EBNF grammar for simple arithmetic expressions with left-associative operators: expression: term {+ term} term: factor {* factor} factor: number ( expression ) How can I convert this into a BNF grammar…
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
7
votes
1 answer

How can I define an INI file grammar using the BNFC?

http://www.cs.chalmers.se/Cs/Research/Language-technology/BNFC/ how should I write my labeled BNF to get BNFC to generate a INI parser for me? I have only gotten so far o__O! entrypoints File ; comment "#" ; token ID ( letter | digit | ["-_'"] )+…
Cetin Sert
  • 4,497
  • 5
  • 38
  • 76
6
votes
1 answer

Extended Backus–Naur Form order of operations

I am creating a formal spec for a very simple rule language, very simple. I want to use EBNF as this is a standard but I can't figure out how to specify order of operations. Here is the specification so far. rule = statement, { (‘AND’|’OR’),…
Dan Walmsley
  • 2,765
  • 7
  • 26
  • 45
6
votes
2 answers

How to consume W3C EBNF-Notation and produce a parser generator?

Throughout the RDF specs an EBNF-NOTATION XML specification is used to specify the grammar of a document. So I am wondering how to use Antlr/bison/yacc (maybe with some flag within these tools I don't know how to search for) — or other tools I don’t…
daidoji70
  • 331
  • 4
  • 13
1
2
3
23 24