Syntax (programming languages)

This Python code is shown with coloring that highlights syntactic aspects.

The syntax of computer source code is the form that it has – specifically without concern for what it means (semantics). Like a natural language, a computer language (i.e. a programming language) defines the syntax that is valid for that language.[1] A syntax error occurs when syntactically invalid source code is processed by an tool such as a compiler or interpreter.

The most commonly used languages are text-based with syntax based on sequences of characters. Alternatively, the syntax of a visual programming language is based on relationships between graphical elements.

When designing the syntax of a language, a designer might start by writing down examples of both legal and illegal strings, before trying to figure out the general rules from these examples.[2]

  1. ^ Friedman, Daniel P.; Mitchell Wand; Christopher T. Haynes (1992). Essentials of Programming Languages (1st ed.). The MIT Press. ISBN 0-262-06145-7.
  2. ^ Smith, Dennis (1999). Designing Maintainable Software. Springer Science & Business Media.

From Wikipedia, the free encyclopedia · View on Wikipedia

Developed by Nelliwinne