Formal Languages Flashcards

1
Q

Why do we have formal languages?

A

We need to communicate with machines. Natural languages are ambiguous and require the understanding of context

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the three keywords used to describe a language

A

Alphabet, syntax and semantics

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is on alphabet

A

It is a non empty finite set of elements that make up a language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How are words formed for a language

A

By concatenating one or more elements from an alphabet

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is syntax in a language

A

Syntax is the form and structure of the language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the 2 types of syntax that describe the structure of a programming language

A

Lexical. Syntax and phrase structured syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is lexical syntax

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How ave lexical syntax defined

A

They ave defined using regular expressions and other formal grammars

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are phrase structured syntax

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How are phrase structured syntax defined

A

They are defined using context free grammars and other formal languages,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are semantics

A

Linguistic meaning of syntactically correct sentences

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an abstract syntax

A

Defines the logical stricture of a program i.e. Algorithms. Not dependendant ona programming
Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is concrete syntax

A

Concrete syntax refers to the specific language or syntax used to express the abstract syntax of a program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a string

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How are elements from an alphabet and words denoted.

A

Lower case beginning letters are used to denote elements of an alphabet while lower case end characters are used to denote strings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can two stings v and W be concatenated

A

By appending w to the end of v

17
Q

What is a reverse of a string

A

It is the string written in reverse order

18
Q

What is lwl

A

It is the length of a string w.

19
Q

What is €

A

It is a empty string of length zero it is I€l=0

20
Q

If w=uv then what are u and V

A

U is the prefix of W and vis the suffix

21
Q

If w=abbcab, then what are the set of prefixes

A

{ A, ab, abb, Abbc, abbca, abbcab }

22
Q

If W is a string, then what is w to the power n

A

W to the power n is the string obtained when w is concatenated by itself n times

23
Q

It £ is an alphabet then what is £ to the power k

A

It is the string of length K that can be obtained from that alphabet

24
Q

What is kleene closure of an alphabet £ ( £ to the power *)

A

It is the set of all possible string from an alphabet