SYNTAX ANALYSER Flashcards

1
Q

what is the job of the syntax analyzer

A

Syntax Analyzer creates the syntactic structure of the given source program.

This syntactic structure is mostly a parse tree. A syntax analyzer is also known as parser.

The syntax analyzer (parser) checks whether a given source program satisfies the rules implied by a context-free grammar or not.

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

The syntax of a programming is described by a ?

A

context-free grammar (CFG).

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

Classifications of errors

A

Lexical errors
Syntactic errors
Semantic errors
Logical errors

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

Describe lexical error

A

These errors are mainly spelling mistakes and accidental insertion of foreign characters, for e.g.. ‘$’, if the language does not allow it. They are mostly caught by the lexical analyzer.

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

Describe syntactic errors

A

Syntactic error: These are grammatical mistakes , such as unbalanced parentheses in arithmetic expressions.

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

Describe semantic errors

A

Semantic error: involve errors due to undefined variables, incompatible operands to an operator etc.

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

Describe logical errors

A

These are errors such as infinite loops. There is not any way to catch the logical error automatically.

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

Goals of the error handler

A
  1. It should report the presence or error cleanly & accurately.
  2. It should recover from each error quickly enough to be able to detect subsequent errors.
  3. It should not significantly slow down the processing of the correct program.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a terminal?

A

A terminal is a discrete symbol that can appear in the language, otherwise known as a token. Examples of terminals are keywords, operators, and identifiers. We will use lower-case letters to represent terminals.
E.g a,b,c,+,-,punc,0,1,…,9,

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

What is a non-terminal

A

A non-terminal represents a structure that can occur in a language, but is not a literal symbol. Example of non-terminals are declarations, statements, and expressions.

We will use upper-case letters to represent non-terminals: P for program, S for statement, E for expression, etc.
E.g A,B,C,S,

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

What is a CFG

A

A context-free grammar (CFG) is a list of rules that formally describe the allowable sentences in a language.

The left-hand side of each rule is always a single non-terminal.

The right-hand side of a rule is a sentential form that describes an allowable form of that non-terminal.

E.g the rule A -> xXy indicates that the non-terminal A represents a terminal x followed by a non-terminal X and a terminal y.

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

A Context Free Grammar, CFG, is described by T, NT, S, PR, where:

A

T: Terminals / tokens of the language
NT: Non-terminals to denote sets of strings generated by the grammar & in the language
S: Start symbol, SNT, which defines all strings of the language
PR: Production rules to indicate how T and NT are combined to generate valid strings of the language.

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

They are two approaches to parsing

A

top-down and bottom-up.

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

What is a sentence?

A

A sentence is a valid sequence of terminals in a language,

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