Syntax and Semantics
- A program has a precise meaning and effect.
- A model of a programming language provides a way of describing the meaning of a program.
- Typically, this is done informally, by examples.
- With Scheme, we can do better.
Advantages of Modeling in Scheme
- There are few language constructs, making the model descriptions short.
- No more than the language itself is necessary. (i.e. No need for diagrams, etc.)
Spelling Rules for Beginning Student
- Identifiers are the names of constants, parameters, and user-defined functions.
- Identifiers must contain at least one non-number and may not contain any spaces or these: ( ) , ; , - * + ‘ “.
- There are rules for numbers (integers, rationals, and decimals).
- Built-in constants such as true and false also exist.
Syntax and Grammar
- There are 3 problems to address:
Syntax: The way in which one is allowed to say something.
?pie like do you
Semantics: The meaning of what we say.
Boots fly hungrily
Ambiguity: A valid sentence has only 1 meaning.
Jameson was given a book by June
- Grammars enforce syntax and help to avoid ambiguity.
- This is similar to the grammar found in spoken languages.
- The issue of semantics can be solved using a semantics model of a programming language.
- The semantics model provides the method of predicting the result of running a program.
- The model