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:
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:
So, what term refers to which syntax, actually?
Thank you for your response!
Abstract vs. Concrete Syntax
Moderator: Konzepte der Programmiersprachen
Re: Abstract vs. Concrete Syntax
I'm confused by this too.
On slide 40 of V04 the syntax is referred to as concrete and the is referred to as abstract. (also here FWAE should be FLAE I believe, which I suppose was a typo).
On slide 40 of V04 the
Code: Alles auswählen
<FWAE> ::= <num> ...
Code: Alles auswählen
sealed abstract class FLAE ...
Re: Abstract vs. Concrete Syntax
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.
But I would really appreciate an official statement on this, though.
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.
-
- Moderator
- Beiträge: 82
- Registriert: 16. Okt 2017 12:28
Re: Abstract vs. Concrete Syntax
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
In essence:
Concrete syntax = what the programmer writes
Abstract syntax = what the interpreter sees (result of parsing 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
Code: Alles auswählen
f 2
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)
Re: Abstract vs. Concrete Syntax
Okay, thank you for the good explanation!