In
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, the abstract syntax of data is its structure described as a
data type
In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it. A data type tells the compiler or interpreter how the programmer intends to use the data. Most progra ...
(possibly, but not necessarily, an
abstract data type
In computer science, an abstract data type (ADT) is a mathematical model for data types. An abstract data type is defined by its behavior (Semantics (computer science), semantics) from the point of view of a ''User (computing), user'', of the dat ...
), independent of any particular representation or encoding. This is particularly used in the representation of text in
computer language
A computer language is a formal language used to communicate with a computer. Types of computer languages include:
* Construction language – all forms of communication by which a human can specify an executable problem solution to a compu ...
s, which are generally stored in a tree structure as an
abstract syntax tree
In computer science, an abstract syntax tree (AST), or just syntax tree, is a tree representation of the abstract syntactic structure of text (often source code) written in a formal language. Each node of the tree denotes a construct occurring ...
. Abstract syntax, which only consists of the structure of data, is contrasted with
concrete syntax
A parse tree or parsing tree or derivation tree or concrete syntax tree is an ordered, rooted tree that represents the syntactic structure of a string according to some context-free grammar. The term ''parse tree'' itself is used primarily in com ...
, 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
In computer science, higher-order abstract syntax (abbreviated HOAS) is a technique for the representation of abstract syntax trees for languages with variable binders.
Relation to first-order abstract syntax
An abstract syntax is ''abstract'' be ...
,'' if the names themselves are abstract.
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
A parse tree or parsing tree or derivation tree or concrete syntax tree is an ordered, rooted tree that represents the syntactic structure of a string according to some context-free grammar. The term ''parse tree'' itself is used primarily in com ...
" (in language implementation) or the "transfer syntax" (in communications).
A
compiler
In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
'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
A parse tree or parsing tree or derivation tree or concrete syntax tree is an ordered, rooted tree that represents the syntactic structure of a string according to some context-free grammar. The term ''parse tree'' itself is used primarily in co ...
is similar to an
abstract syntax tree
In computer science, an abstract syntax tree (AST), or just syntax tree, is a tree representation of the abstract syntactic structure of text (often source code) written in a formal language. Each node of the tree denotes a construct occurring ...
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 type
In computer programming, especially functional programming and type theory, an algebraic data type (ADT) is a kind of composite type, i.e., a type formed by combining other types.
Two common classes of algebraic types are product types (i.e., t ...
s are particularly well-suited to the implementation of abstract syntax.
See also
*
Higher-order abstract syntax
In computer science, higher-order abstract syntax (abbreviated HOAS) is a technique for the representation of abstract syntax trees for languages with variable binders.
Relation to first-order abstract syntax
An abstract syntax is ''abstract'' be ...
*
Abstract Syntax Notation One
Abstract Syntax Notation One (ASN.1) is a standard interface description language for defining data structures that can be serialized and deserialized in a cross-platform way. It is broadly used in telecommunications and computer networking, and ...
References
Programming language design
Programming language theory
Compiler construction
Syntax
Parsing
{{prog-lang-stub