Abstract syntax explained

In computer science, the abstract syntax of data is its structure described as a data type (possibly, but not necessarily, an abstract data type), independent of any particular representation or encoding.[1] This is particularly used in the representation of text in computer languages,[2] which are generally stored in a tree structure as an abstract syntax tree. Abstract syntax, which only consists of the structure of data, is contrasted with concrete syntax, which also includes information about the representation. For example, concrete syntax includes features like parentheses (for grouping) or commas (for lists), which are not included in the abstract syntax, as they are implicit in the structure.

Abstract syntaxes are classified as first-order abstract syntax (FOAS), if the structure is abstract but names (identifiers) are still concrete (and thus requires name resolution), and higher-order abstract syntax, if the names themselves are abstract.[3]

Uses

To be implemented either for computation or communications, a mapping from the abstract syntax to specific machine representations and encodings must be defined; these may be called the "concrete syntax" (in language implementation)[4] or the "transfer syntax" (in communications).

A compiler's internal representation of a program will typically be specified by an abstract syntax in terms of categories such as "statement", "expression" and "identifier". This is independent of the source syntax (concrete syntax) of the language being compiled (though it will often be very similar). A parse tree is similar to an abstract syntax tree but it will typically also contain features such as parentheses, which are syntactically significant but which are implicit in the structure of the abstract syntax tree.

Algebraic data types are particularly well-suited to the implementation of abstract syntax.[5]

See also

Notes and References

  1. Book: https://ieeexplore.ieee.org/document/782615 . 2023-11-02 . 1999 . 10.1109/LICS.1999.782615 . 7384052 . en-US . Fiore . M. . Gordon Plotkin. Plotkin . G. . Turi . D. . Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158) . Abstract syntax and variable binding . 193–202 . 0-7695-0158-3 .
  2. Book: https://dl.acm.org/doi/abs/10.5555/1267950.1267968 . ASTLOG: A language for examining abstract syntax trees . DSL'97: Proceedings of the Conference on Domain-Specific Languages on Conference on Domain-Specific Languages (DSL), 1997 . USENIX Association . 15 October 1997 . 18 .
  3. Pfenning . F. . Frank Pfenning. Elliott . C. . 1988-06-01 . Higher-order abstract syntax . . 23 . 7 . 199–208 . 10.1145/960116.54010 . 0362-1340. free .
  4. Book: Wile, David S. . Proceedings of the 19th international conference on Software engineering - ICSE '97 . Abstract syntax from concrete syntax . 1997 . http://portal.acm.org/citation.cfm?doid=253228.253388 . en . ACM Press . 472–480 . 10.1145/253228.253388 . 978-0-89791-914-2. 14351497 .
  5. Corradini . Andrea . Gadducci . Fabio . A functorial semantics for multi-algebras and partial algebras, with applications to syntax . Theoretical Computer Science . 2002-09-17 . 286 . 2 . 293–322 . 10.1016/S0304-3975(01)00319-X . 0304-3975. free .