Abstract syntax allows programmers to map out a program’s structure without worrying about implementation details. It outlines program-specific tasks and data types, which are matched with concrete syntax when creating an abstract syntax tree. This approach is useful in compiler theory and helps create error-free code.
Abstract syntax is a way for computer programmers to map out the structure of the program they want to create without worrying about the actual code needed to implement it. It allows the programmer to focus on what the program needs to do before focusing on getting the computer to actually perform the desired functions. The abstract syntax outlines program-specific tasks, such as adding two numbers together, and shows what data types can be used within that program. Once the abstract mapping is complete, an abstract syntax tree is drawn, matching abstract concepts with concrete syntax: the actual symbols a programmer must type to run the program he is creating.
The idea for abstract syntax is to focus on data types and their relationships without getting caught up in the details of how to encode them. Computer code is very different from human language, and trying to think in those terms is difficult. Instead, programmers list the steps the program must complete and then use concrete syntax to match the abstract terms to terms in the computer code that perform those steps. Often, the programmer will include data types in his abstract markup to show what data types, whether numbers, letters, or decimals, the program can work with. However, specific data types are not required at this stage of programming, and the programmer may choose to use abstract data types, which are purely theoretical and will be replaced with specific data types when the program is written.
This sort of abstract programming idea is often used in compiler theory. Computers can only understand two values: 1 and 0. This is known as binary code. For the computer to understand a program written in a programming language, it has to compile or translate the words and letters in a stream of 1s and 0s. Compilers are complex to create and map out a vague or abstract idea of what they need to do helps a programmer plan error-free code.
When the programmer wants to map abstract syntax to concrete syntax and start coding the program or compiler, he creates an abstract syntax tree. This is simply a list of all the abstract statements he wrote, such as “add 2 variables”, with a line drawn from each abstract term to the specific line of code needed to execute that statement. The programmer can use as many abstract terms as he likes, but it is more common to use familiar code terms such as “var” for variable and “int” for integer.
Protect your devices with Threat Protection by NordVPN