Abstract vs. Concrete Syntax

Moderator: Konzepte der Programmiersprachen

topracer
Mausschubser
Mausschubser
Beiträge: 53
Registriert: 10. Jan 2014 19:14

Abstract vs. Concrete Syntax

Beitrag von topracer » 24. Feb 2019 11:40

Hello,

I noticed that in the slides the terms "abstract" and "concrete syntax" are used inconsistently... On the definition slide (p. 4) of V02, Abstract syntax seems to refer to the <AE> ::= ... notation:
VL02_Abstract_Concrete_Syntax.png
VL02_Abstract_Concrete_Syntax.png (87.29 KiB) 125 mal betrachtet
However, in V03 e.g. on p. 8 the same notation is named "concrete syntax" and the term "abstract syntax" refers to the Scala syntax:
VL03_Abstract_Concrete_Syntax.png
VL03_Abstract_Concrete_Syntax.png (104.61 KiB) 125 mal betrachtet
So, what term refers to which syntax, actually?

Thank you for your response!

nicolas_m
Erstie
Erstie
Beiträge: 11
Registriert: 14. Jun 2013 16:13

Re: Abstract vs. Concrete Syntax

Beitrag von nicolas_m » 25. Feb 2019 15:53

I'm confused by this too.

On slide 40 of V04 the

Code: Alles auswählen

<FWAE> ::= <num> ...
syntax is referred to as concrete and the

Code: Alles auswählen

sealed abstract class FLAE ...
is referred to as abstract. (also here FWAE should be FLAE I believe, which I suppose was a typo).

topracer
Mausschubser
Mausschubser
Beiträge: 53
Registriert: 10. Jan 2014 19:14

Re: Abstract vs. Concrete Syntax

Beitrag von topracer » 25. Feb 2019 18:24

According to what I found here the non-Scala syntax seems to be the concrete syntax and the Scala representation the abstract one. (That also roughly matches the definition slide in the lecture, except for the example being in the wrong place.)

But I would really appreciate an official statement on this, though.
nicolas_m hat geschrieben:
25. Feb 2019 15:53
also here FWAE should be FLAE I believe, which I suppose was a typo
I think this is the same naming inconvenience which is discussed here. The "W" stands for "with", which is the equivalent to "let" that is used in the PLAI book.

mirko-koehler
Moderator
Moderator
Beiträge: 66
Registriert: 16. Okt 2017 12:28

Re: Abstract vs. Concrete Syntax

Beitrag von mirko-koehler » 26. Feb 2019 10:41

Concrete syntax is how the code looks to the programmer. The abstract syntax are the syntax trees that result from parsing the concrete syntax.

In our interpreters, the abstract syntax are the expression case classes (e.g. App(funName: Symbol, ...) ). The expressions build expression trees that are then used by the interpreters and type checkers. We did not care much about concrete syntax: the programs are written with the abstract syntax.

In Slide V02 p.4, we use a grammar to define how the abstract syntax trees of some language look like (we then introduce case classses to model these trees in Scala). In Slide V03 p.8, we use a grammar to define how the programmer is writing code. A programmer would write instead of

Code: Alles auswählen

App('f, 2)

In essence:
Concrete syntax = what the programmer writes
Abstract syntax = what the interpreter sees (result of parsing concrete syntax)

topracer
Mausschubser
Mausschubser
Beiträge: 53
Registriert: 10. Jan 2014 19:14

Re: Abstract vs. Concrete Syntax

Beitrag von topracer » 1. Mär 2019 10:59

Okay, thank you for the good explanation!

Antworten

Zurück zu „Konzepte der Programmiersprachen“