EBNF???? (1 Viewer)

Kittyrules

I'm your density
Joined
Mar 23, 2014
Messages
534
Gender
Female
HSC
2016
Hi guys,

Im getting quite confused about EBNF and railroad diagrams and how they define data structures.

So I understand that EBNF is a meta-language that describes the syntax of other languages and that:

= means defined as
<> is put around non terminal indicators
{} is for repetition
[] is for optional elements
and () for groups

I get how to define words, and boolean, identifiers and letters and stuff like that, but not really how to define a while statement or a for loop... also im not quite sure how that works in railroad diagrams either. Like how do i use the keywords 'if' and 'then' in the railroad diagram ahhhh

if anyone could explain i would be very grateful! and sorry for my bad explanation of my issue
 

GoldyOrNugget

Señor Member
Joined
Jul 14, 2012
Messages
583
Gender
Male
HSC
2012
I did SDD. Railroad diagrams and EBNF don't describe data structures, they describe languages (sets of strings).

EBNF can't be used to define a for loop or define a while loop. It's used to define the syntax for these constructs. Like, you might describe the syntax for a while loop as


while = "while (", condition, ") {", {statement}, "}" ;
condition = value, sign, value ;
sign = "<" | ">" | "=" ;
value = number | variable ;
variable = "A" | "B" | ... | "Z" ;
number = "1" | "2" | ... | "9" | "0" ;

...and so on.

In a railroad diagram, keywords would be literals. So it would be a rounded-rectangle with the keyword "if" or "then".
 

OverSeaRoad

New Member
Joined
Jun 14, 2016
Messages
1
Gender
Undisclosed
HSC
2017
EBNF
Stands for Extended Backus Naur Form
Was created by John Backus and later updated by Peter Naur it was then extended and that's why there's the word extended there.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top