Syntax Flashcards
syntax
the form or structure of the expressions, statements and program units (formal method to describe how to determine a statement’s set membership in a Language)
semantics
the meaning of the expressions, statements, and program units
grammar
formal description of a Language
sentence
a string of characters over some alphabet
language
a set of sentences (characterized by the set of all valid statements / strings in that language.
The cardinality of this set is potentially infinite)
lexeme
lowest level syntactic unit of a language
token
category of lexemes
recognizers; generators
grammars can be formally utilized in two distinct ways: for ____ and for ___. (two approaches to describing syntax)
Recognition device
___ device reads input strings over the alphabet of the language and decides whether the input strings belong to the language (i.e.syntax analysis part of a compiler)
Generators
A device that generates sentences of a language (one can determine if the syntax of a particular sentence is syntactically correct by comparing it to the structure of the generator
grammars
what is the formal language-generation mechanism commonly used to describe the syntax of programming languages
Backus-Naur Form (BNF) is equivalent to
Context-Free Grammars
Context Free Grammar syntax
Grammar = (Start symbol, set of Non-terminals, set of Terminals, set of Production Rules)
define non-terminal symbols
abstractions are used to represent classes of syntactic structures; they act like syntactic variables (often enclosed in angle brackets <>)
define terminal symbols
they are lexemes