Skip to content

Jay-tech456/Generating_Syntatically_correct_program_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Generating_Syntatically_correct_program_python

This program creates a random "syntactically" correct program

In order toprogram, we must understand the difference between a syntatically correct program versus and semantically correct program.

When a program is "syntatically" correct, it follows the general rule of the program's grammer. In english language, we are taught to capitalize the first letter in the sentence, have a noun, a verb after the noun, and a punctuation at the end of the sentence. Programming is no difference, we still have to follow the rules of grammer that is present within the programs syntax.

  A sentence that is syntatically correct:
      The hamburger tastes good.
      
  A program that is syntatically correct (C++)
        #include <iostream>
         using namespace std;
         
        int main() {
            cout << "Hello world " << endl;
         }

When a program is "semantically" correct translates to everything in the program makes logically sense and there is no error. Going back to grade school, we were taught that 2 + 2 has to equal 4, and it is valid. Programming follows through a similar position where everything in the program has to make logical sence. In C++, we have to declare the necessary libraries, have a main with a single well-defined entry point and a single well-defined exit point, does your variable matches the primative data type, is your 'if' else statement properly declared, etc.

A program can be syntatically correct, but not semantically correct; however, it will not run and often throw an error. For example: An english sentence that is syntatically correct, but not semantically correct is: "The Car's color is hamburger " " The wrestling tournament was pancakes "

        Syntatically, these sentances are correct, but semantically they are not 

Here is a program that generates a random syntatically correct program.

About

This program creates a random "syntactically" correct program

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages