3.1.1 Syntax

On the previous page, you saw an example of a specification of syntax. It specifies how to write a part of the Prolog+CG language. We repeat it here:

Supertype > Subtype1, Subtype2, ..., SubtypeN.

It's like a recipe

This is just like a recipe for a cake. It describes the syntax of Prolog+CG type hierarchies.

The meaning of syntax

"Syntax" comes from Greek, "syn" (which means "together") and "taxis" (which comes from "tasso", which means "I arrange"). So it means "together-arrangement".

The syntax of a programming language specifies how to put together certain parts of the language into larger wholes.

For example, the syntax you have just seen specifies how to build:

  • a larger whole (i.e., a type-hierarchical rule)
  • from smaller parts (e.g., the supertype, the ">", the subtypes, etc.).

Why you must know

The computer is stupid and is not able to guess what you had in mind if you don't follow the syntax-rules. Therefore, it is picky about syntax.

You must be careful to get the details right when writing a type-hierarchy. For example:

  • remembering the period at the end,
  • remembering each comma between the subtypes,
  • turning the ">" the right way (it's not a "<").

The computer will help

But don't worry if you get it wrong. You will be told if something is wrong, so you can correct it.

The Prolog+CG program will complain with a "syntax error", which just means it wasn't able to understand what you wrote.

In such cases, try to figure out what is wrong, and correct it and try again. It's as simple as that.

Next

Next, we give an example of how to construct a type-hierarchy given the rule we've learned.


PrevLite: 3.1 Concept types and type-hierarchies in Prolog+CG
NextLite: 3.1.2 Example

Prev: 3.1 Concept types and type-hierarchies in Prolog+CG
Up: 3.1 Concept types and type-hierarchies in Prolog+CG
Next: 3.1.2 Example