Metasyntax
I’ve started this course CS101. It talks about programming, and uses Python. So i decided it’s a good idea to learn Python among other CS stuff. Since my major was not computer science.
One of lectures that drew my attention, is about Grammer of programming languages, and how to define the allowable structure of a programming language statement. Which is also called Metasyntax.
According to Wikipedia, what metasyntax does is it :
describes the allowable structure and composition of phrases and sentences of a metalanguage, which is used to describe either a natural language or a computer programming language.
Metalanguage is the language or symbols you use when you examine some kind of a language.
And the preceding lecture was about Backus Naur Form, which is one of the ways we can examine a language with.
According to Wikipedia :
In computer science, BNF (Backus Normal Form or Backus–Naur Form) is one of the two main notation techniques for context-free grammars, often used to describe the syntax of languages used in computing, such as computer programming languages, document formats, instruction sets and communication protocol.
But what is Context-free grammar? It’s like the grammar used to produce a language, this language is called Context-free language. It uses that production rule :
V → w
Where V is called a nonterminal symbol. The non-terminal symbol is the symbol which can be replaced with another one. In other word, you can break it down to a smaller unit w. this unit could be another non-terminal symbol, or a terminal symbol. A terminal symbol is the symbol which cannot be replaced with another symbol. It represents the ending of the replacement process you make.
In another way you can examine it like this :
z = y y = x x = 5 print z
Here, in the code above, x, y and z, are called non-terminal symbols. And the number 5 is called a terminal symbol, since it can’t be replaced with another symbol anymore.
According to Wikipedia :
Quoting the so-called Dragon Book (a standard reference on the latter subject):
In a compiler, the lexical analyzer reads the characters of the source program, groups them into lexically meaningful units called lexemes, and produces as output tokens representing these lexemes. A token consists of two components, a token name and an attribute value. The token names are abstract symbols that are used by the parser for syntax analysis. Often, we shall call these token named terminals, since they appear as terminal symbols in the grammar for a programming language.
Honestly, i didn’t want to dive deep into this subject. I feel like i got what i needed to know from it. You can either read those Wikipedia article or search for how compilers work and how they treat terminal and non-terminal symbols.
Good luck.