Can we represent the rules or grammar for constructing sentences for the simple English statements on the sentences page as:
<Sentence> -> <Noun Phrase> <Verb> <Noun Phrase>
<Noun Phrase> -> [ <Preposition> ] <Article> <Noun>
<Preposition> -> after | on
<Article> -> the
<Noun> -> dog | cat | fence
<Verb> -> ran | sat.
The symbols used are interrupted as:
The first rule of the grammar defines a sentence as a noun phrase followed by a verb followed by a noun phrase. The last rule defines a verb as either ran or sat.
In programming languages, we would refer to such rules as defining the syntax of the language. Using such rules, we should be able to determine whether a particular sentence is valid for a given language. Is the following sentence valid in terms of the rules specified above?
The fence ran on the cat.
With spoken or written languages, it is in theory possible to devise such rules to define all valid sentences in the language. However, the number of alternatives is extremely large. As a result, we seldom formally define a spoken or written language, although, we may use such rules to teach a language supported by some explanation of what we mean by a noun clause.
One of the major tasks of a compiler for programming languages is verifying that your code is written according to the syntax rules for the language that you are using. This is very similar to a grammar checker in a word processor. The difference is that the syntax rules for a programming language has less ambiguity or options for each sentence. When you get an error during compilation, the error message will indicate whether the syntax problems.
Used in a course, this would be linked to a discussion forum so that students could discuss the issues raised on this page.