Question

I am currently reading the Dragonbook.

In chapter 2, it explains the Syntax Analysis process. I'm struggling to understand the entire picture of this process. By reading the book, I'm sometimes confused in what order things in the syntax analyzer happen.

So from my understanding:

A syntax analyzer contains a syntax definition, which defines a grammar using context free grammar. Is this basically 'the first part' of the syntax analyzer? So does the syntax analyzer include a syntax definition?

After that, the generated tokens by the Lexical Analyzer go into the Syntax Analyzer. The syntax analyzer then check, via CFG if the string input is valid by generating a parse tree.

And from my understanding, this parse tree will eventually become an (abstract) syntax tree (which contains less detail than the parse tree). This tree will go into the semantic analyzer.

Can someone please confirm whether my roughly ''overall picture'' understanding of the syntax analyzer is correct and in the right order?

No correct solution

OTHER TIPS

A syntax analyzer contains a syntax definition, which defines a grammar using context free grammar.

No. In table-driven parsers it contains a table which has been generated from the grammar and which drives the parser. In hand-written parsers, the code structure strongly reflects the grammar. In neither case would it be correct to say that the parser actually 'contains' the grammar. It parses the input, according to the grammar, somehow.

Is this basically 'the first part' of the syntax analyzer?

No. I don't know where you get 'first part' from.

So does the syntax analyzer include a syntax definition?

Only as described above.

After that

No, before that

the generated tokens by the Lexical Analyzer go into the Syntax Analyzer. The syntax analyzer then check, via CFG if the string input is valid

Correct.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top