Das Video kommt von YouTube: erst beim Abspielen verbindet sich die Seite mit YouTube (Google).
Backus-Naur Form
Das Wichtigste aus dem Video
Tipp auf eine Zeit – das Video springt genau dorthin.
Transkriptautomatisch erstellt · 47 Zeilen
- is there a convenient way to express language and syntax in Computing is it possible to express this in an abstract yet minimalist way that still actually
- encompasses the entire idea of the language well we are moving into pretty deep Waters here but this is definitely possible more on this after the
- break this is z612 TV welcome hello YouTube and welcome to another random Wednesday video today we're going to be taking a look at a Computing
- notation called the backers nor form or BNF for short as mentioned in the intro we are looking for a way to express a language a grammar or syntax in a
- simplified yet all-encompassing kind of manner but I'm going to try and make this easy to understand for you so we're going to start off simple and kind of
- pile on the difficulty as we go on so to kick things off here's how we actually make use of BNF basically BNF is just a series of lines of plain text and the
- idea of all these lines is to have a symbol and actually Define the symbol after defining a symbol once we can use it again in future lines so let's start
- off very simple let's say now we have this now how do we read this line basically we'll read it from left to right like so a letter is defined as a
- that's it that is all there is to this line now clearly you know this isn't a very useful definition and definitely not a very complete definition so what
- we want to do is to somehow include you know the rest of the letters in this definition to do that we use the pipe of vertical bar symbol and in this context
- it stands for all so what this means then is if I were to say this you would read it as a letter is defined as a or B or C or D and so on I hope you're
- following me so far up to this point we've taken a look at the concept of a definition as well as the all symbol which of course will help us make our
- definitions a little bit more Dynamic now if you want to consider the mechanics provided to you by the BNF syntax basically we've already looked at
- it all yes really just the idea of definitions and the idea of using the All symbol essentially that is all we have however there is one more thing we
- can do and that is what makes BNF so Dynamic what we are about to do is to actually exploit on the concept of a definition now take a look at this we
- have a letter so far well that's not very interesting let us try to form words you may be wondering how you know a word will look like well guess what
- this definition is extremely short a word is defined as a letup or or a word attached to a letter now let's take a closer look at this a word is defined as
- a letter well that's fine you can have you know words that are of just one letter however that's not interesting we want to be able to build a longer word
- than that and that's when we actually look at the second part of the definition now if you've had any Computing experience you realize that
- this is actually a recursive definition and well I suppose have to tell you what recursive means well it means recursive formally a recursive definition is a
- definition that makes use of its own definition to Define itself that sounds a little counterintuitive but I'm going to show you how this works in terms of
- BNF and you'll see how powerful it is so okay let's start off simple we're going to actually use the most basic definition of a word and that is simply
- a letter so we have a letter however because of this part of the definition what this means is that this letter is also a word
- so let's look at this as a word instead of a letter what we're going to do then is we're going to form the rest of our word what can we do with words remember
- that a word is defined as a word with a letter attached to it what this means is that if we were to grab a letter and stick it to the end of that right now
- this still fits the definition of a word all of a sudden we have a word that is made of two letters what we can then do is we can actually stick more letters to
- the end of this and however many we add this is still a word and that is actually what makes BNF so extremely flexible by making use of recursive
- definitions we can actually do pretty crazy things we can create strings of any length and if we have several more lines we can really start creating very
- interesting combinations now just to show you that this can indeed be practical let's move on and do something even more complex to our existing
- definition bear in mind that with just these two lines we can actually start synthesizing words of any length let us now try and make full sentences what
- we're going to do first is we have actually going to define a phrase as always we start off with the basic case a phrase is a word that's fine then we
- move on to the crazy amazing recursive definition we add the all symbol and then we say phrase space word so let's break this down here I'm sure you have a
- very rough understanding of what's going on right now but let's try and make it more explicit so a phrase can be a word that's simple that is our base case or a
- phrase can be a phrase attached to a space attached to a word now this is slightly different from our synthesizing words seeing I said within actually
- specially add a space character however the concept Remains the Same obviously if you only sit this then what we're going to do is we're going to just take
- the words and stick them back to back and that doesn't work correctly so so instead what we're going to do is we're going to space our words out and we can
- actually just Define a constant within our definition so basically when you want to make use of this definition you have your words you have to add a space
- before you can tag on the next word using this definition recursively works exactly the same as letters so well we can just have words and stick more and
- more of them together and the whole thing still counts as a phrase and there you go that is basically how you would use BNF to build up syntax rules for an
- entire language essentially we've just defined how English works we can go on to add say punctuation we can go on to add you know definitions for sentences
- obviously we do need to come up with a rigorous set of definitions so we don't miss out anything in the grammar but as things stand so far we can actually
- already creates full sentences and there you go that will be the back ASN form of BNF before we wrap up this video let's take a look at something interesting
- well guess what the way BNF Works can be defined in BNF now to give credit where credit is due I actually ripped this off Wikipedia so you can go there and
- actually check out more interesting things about BNF but yeah that's it that's all there is for this Wednesday episode if you have any comments queries
- or suggestions feel free to leave a comment in the comment section below don't forget to follow the official Twitter account for this Channel at
- twitter.com / 0612 TV as always I appreciate every like favorite and subscription you give me but until next time you're watching 0612
- TV
Zum Nachlesen
Backus-Naur-FormDie Backus-Naur-Form oder Backus-Normalform (kurz BNF) ist eine kompakte formale Metasprache zur Darstellung kontextfreier Grammatiken (Typ-2-Grammatiken in …
Erweiterte Backus-Naur-FormDie Erweiterte Backus-Naur-Form, kurz EBNF, ist eine Erweiterung der Backus-Naur-Form (BNF), die ursprünglich von Niklaus Wirth zur Darstellung der Syntax …
SyntaxdiagrammJede Erweiterte Backus-Naur-Form (EBNF) kann mithilfe der nebenstehenden Grafik eins zu eins in ein Syntaxdiagramm umgewandelt werden. Beispiel. Bearbeiten.
Formale SpracheEine formale Sprache ist eine abstrakte Sprache, bei der im Unterschied zu natürlichen Sprachen oft nicht die Kommunikation im Vordergrund steht, …