Syntax and Semantics
ALGOL W's syntax is built on a subset of the EBCDIC character set. In ALGOL 60 reserved words are distinct lexical items, but in ALGOL W they are merely sequences of characters, and do not need to be stropped. Reserved words and identifiers are separated by spaces. In these ways ALGOL W's syntax resembles that of Pascal and later languages.
The Algol W Language Description defines Algol W in an affix grammar that resembles BNF. This grammar was a precursor of the Van Wijngaarden grammar.
Much of Algol W's semantics is defined grammatically:
- Identifiers are distinguished by their definition within the current scope. For example, a ⟨procedure identifier⟩ is an identifier that has been defined by a procedure declaration, a ⟨label identifier⟩ is an identifier that is being used as a goto label.
- The types of variables and expressions are represented by affixes. For example ⟨τ function identifier⟩ is the syntactic entity for a function that returns a value of type τ, if an identifier has been declared as an integer function in the current scope then that is expanded to ⟨integer function identifier⟩.
- Type errors are grammatical errors. For example "⟨integer expression⟩ / ⟨integer expression⟩" and "⟨real expression⟩ / ⟨real expression⟩" are valid but distinct syntactic entities that represent expressions, but "⟨real expression⟩ DIV ⟨integer expression⟩" (i.e. integer division performed on a floating-point value) is an invalid syntactic entity.
Read more about this topic: ALGOL W
Famous quotes containing the words syntax and:
“Syntax and vocabulary are overwhelming constraintsthe rules that run us. Language is using us to talkwe think were using the language, but language is doing the thinking, were its slavish agents.”
—Harry Mathews (b. 1930)