Formal Languages Flashcards
Why do we have formal languages?
We need to communicate with machines. Natural languages are ambiguous and require the understanding of context
What are the three keywords used to describe a language
Alphabet, syntax and semantics
What is on alphabet
It is a non empty finite set of elements that make up a language
How are words formed for a language
By concatenating one or more elements from an alphabet
What is syntax in a language
Syntax is the form and structure of the language
What are the 2 types of syntax that describe the structure of a programming language
Lexical. Syntax and phrase structured syntax
What is lexical syntax
It is a type of syntax which describes the structure of a programming language.it defines how individual components come together to form meaning full tokens.it helps a computer understand which words, numbers or symbols are important and which are not, by defining keywords, operators and identifiers.
How ave lexical syntax defined
They ave defined using regular expressions and other formal grammars
What are phrase structured syntax
They describe the structure of a programming language. They define hour tokens come together to form larger structures such as expressions, functions and statements.it helps a computer understat how the may components fit together to create meaning. Eg: order of arithmetic operations, structure of control statements such if/else, syntax for function declaration and calls.
How are phrase structured syntax defined
They are defined using context free grammars and other formal languages,
What are semantics
Linguistic meaning of syntactically correct sentences
What is an abstract syntax
Defines the logical stricture of a program i.e. Algorithms. Not dependendant ona programming
Language
What is concrete syntax
Concrete syntax refers to the specific language or syntax used to express the abstract syntax of a program.
What is a string
It is a word. Made by concatenating one or more elements from an alphabet. It is a finite sequence of symbols from an alphabet.
How are elements from an alphabet and words denoted.
Lower case beginning letters are used to denote elements of an alphabet while lower case end characters are used to denote strings