A structure editor, also structured editor or projectional editor, is any document editor that is cognizant of the document's underlying
structure
A structure is an arrangement and organization of interrelated elements in a material object or system, or the object or system so organized. Material structures include man-made objects such as buildings and machines and natural objects such as ...
. Structure editors can be used to edit hierarchical or
marked up text
Text may refer to:
Written word
* Text (literary theory)
In literary theory, a text is any object that can be "read", whether this object is a work of literature, a street sign, an arrangement of buildings on a city block, or styles of clothi ...
,
computer program
A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
s,
diagram
A diagram is a symbolic Depiction, representation of information using Visualization (graphics), visualization techniques. Diagrams have been used since prehistoric times on Cave painting, walls of caves, but became more prevalent during the Age o ...
s,
chemical formula
A chemical formula is a way of presenting information about the chemical proportions of atoms that constitute a particular chemical compound or molecule, using chemical element symbols, numbers, and sometimes also other symbols, such as pare ...
s, and any other type of content with clear and well-defined structure. In contrast, a
text editor
A text editor is a type of computer program that edits plain text. An example of such program is "notepad" software (e.g. Windows Notepad). Text editors are provided with operating systems and software development packages, and can be used to c ...
is any document editor used for editing plain
text file
A text file (sometimes spelled textfile; an old alternative name is flat file) is a kind of computer file that is structured as a sequence of lines of electronic text. A text file exists stored as data within a computer file system.
In ope ...
s.
Typically, the benefits of text and structure editing are combined in the
user interface
In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine fro ...
of a single hybrid tool. For example,
Emacs
Emacs (), originally named EMACS (an acronym for "Editor Macros"), is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, s ...
is fundamentally a text editor, but supports the manipulation of words, sentences, and paragraphs as structures that are inferred from the text. Conversely,
Dreamweaver
Adobe Dreamweaver is a proprietary web development tool from Adobe. It was created by Macromedia in 1997 and developed by them until Macromedia was acquired by Adobe Systems in 2005.
Adobe Dreamweaver is available for the macOS and Windows opera ...
is fundamentally a structure editor for marked up web documents, but supports the display and manipulation of raw
HTML
Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. It defines the content and structure of web content. It is often assisted by technologies such as Cascading Style Sheets ( ...
text as well. Similarly,
molecule editor
A notable molecule editor is a computer program for creating and modifying representations of chemical structures.
Molecule editors can manipulate chemical structure representations in either a simulated two-dimensional space or three-dimensional ...
s typically support both graphical and textual input. Structure editing predominates when content is
graphical
Graphics () are visual images or designs on some surface, such as a wall, canvas, screen, paper, or stone, to inform, illustrate, or entertain. In contemporary usage, it includes a pictorial representation of the data, as in design and manufactu ...
and textual representations are awkward, e.g.,
CAD
Computer-aided design (CAD) is the use of computers (or ) to aid in the creation, modification, analysis, or optimization of a design. This software is used to increase the productivity of the designer, improve the quality of design, improve c ...
systems and
PowerPoint. Text editing predominates when content is largely devoid of structure, e.g., text fields in web forms.
WYSIWYG
In computing, WYSIWYG ( ), an acronym for what you see is what you get, refers to software that allows content to be edited in a form that resembles its appearance when printed or displayed as a finished product, such as a printed document, web ...
word processing systems such as
Word
A word is a basic element of language that carries semantics, meaning, can be used on its own, and is uninterruptible. Despite the fact that language speakers often have an intuitive grasp of what a word is, there is no consensus among linguist ...
, which appear to edit formatted text directly, are essentially structure editors for the underlying marked-up text.
In
linguistics
Linguistics is the scientific study of language. The areas of linguistic analysis are syntax (rules governing the structure of sentences), semantics (meaning), Morphology (linguistics), morphology (structure of words), phonetics (speech sounds ...
,
syntax
In linguistics, syntax ( ) is the study of how words and morphemes combine to form larger units such as phrases and sentences. Central concerns of syntax include word order, grammatical relations, hierarchical sentence structure (constituenc ...
is the study of the structure of grammatical utterances, and accordingly syntax-directed editor is a synonym for structure editor. Language-based editor and language-sensitive editor are also synonyms. A language-based editor's features may be implemented by ad hoc code or by a
formal grammar
A formal grammar is a set of Terminal and nonterminal symbols, symbols and the Production (computer science), production rules for rewriting some of them into every possible string of a formal language over an Alphabet (formal languages), alphabe ...
. For example, language sensitivity in Emacs is implemented in the
Lisp
Lisp (historically LISP, an abbreviation of "list processing") is a family of programming languages with a long history and a distinctive, fully parenthesized Polish notation#Explanation, prefix notation.
Originally specified in the late 1950s, ...
definition of the edit mode for the given language. In contrast, language sensitivity in an
XML editor
An XML editor is a markup language editor with added functionality to facilitate the editing of XML. This can be done using a plain text editor, with all the code visible, but XML editors have added facilities like tag completion and menus and bu ...
is driven by a formal
DTD schema for the given language.
Although structured editors allow the viewing and manipulation of the underlying document in a structured manner, the file format in which the document is stored on disk may or may not be heavily structured and may or may not be open or standardized (e.g., plain text versus Microsoft Word documents).
Structure editing has often been employed in
source code editor
A source-code editor is a text editor program designed specifically for editing source code of computer programs. It may be a standalone application or it may be built into an integrated development environment (IDE).
Features
Source-code editor ...
s, as source code is naturally structured by the syntax of the computer language. However, most source code editors are instead text editors with additional features such as
syntax highlighting
Syntax highlighting is a feature of text editors that is used for programming language, programming, scripting language, scripting, or markup language, markup languages, such as HTML. The feature displays text, especially source code, in differe ...
and
code folding
Code or text folding, or less commonly holophrasting, is a feature of some graphical user interfaces that allows the user to selectively hide ("fold") or display ("unfold") parts of a document. This allows the user to manage large amounts of text ...
, rather than structure editors. The editors in some
integrated development environment
An integrated development environment (IDE) is a Application software, software application that provides comprehensive facilities for software development. An IDE normally consists of at least a source-code editor, build automation tools, an ...
s parse the source code and generate a parse tree, allowing the same analysis as by a structure editor, but the actual editing of the source code is generally done as raw text.
Each
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
typically has a well-defined syntax given by a
context-free grammar
In formal language theory, a context-free grammar (CFG) is a formal grammar whose production rules
can be applied to a nonterminal symbol regardless of its context.
In particular, in a context-free grammar, each production rule is of the fo ...
, and accordingly the meaningful structural elements in
source code
In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.
Since a computer, at base, only ...
written in the language correspond to the grammatical
phrases
In grammar, a phrasecalled expression in some contextsis a group of words or singular word acting as a grammatical unit. For instance, the English expression "the very happy squirrel" is a noun phrase which contains the adjective phrase "very ...
in the text. Early syntax-directed source code editors included
Interlisp-D (for
Lisp
Lisp (historically LISP, an abbreviation of "list processing") is a family of programming languages with a long history and a distinctive, fully parenthesized Polish notation#Explanation, prefix notation.
Originally specified in the late 1950s, ...
’s limited syntax) and Emily
(for
PL/I
PL/I (Programming Language One, pronounced and sometimes written PL/1) is a procedural, imperative computer programming language initially developed by IBM. It is designed for scientific, engineering, business and system programming. It has b ...
’s rich syntax).
A syntax-directed editor may treat grammar rules as
generative (e.g., offering the user
templates that correspond to one or more steps in a formal derivation of program text) or proscriptive (e.g., preventing a phrase of a given
part of speech
In grammar, a part of speech or part-of-speech ( abbreviated as POS or PoS, also known as word class or grammatical category) is a category of words (or, more generally, of lexical items) that have similar grammatical properties. Words that are ...
from being moved to a context where another part of speech is required) or analytic (e.g., parsing textual edits to create a structured representation). Structure editing features in source code editors make it harder to write programs with invalid syntax. Language-sensitive editors may impose syntactic correctness as an absolute requirement (e.g., as did Mentor
), or may tolerate
syntax errors after issuing a warning (e.g., as did the Cornell Program Synthesizer
). Strict structured editors often make it difficult to perform edits that are easy to perform with plain text editors, which is one of the factors contributing to the lack of adoption of structured editing in some domains, such as source code editing.
Some syntax-directed editors monitor compliance with the
context-sensitive constraints of a language such as
type correctness. Such
static-semantic constraints may be specified
imperatively by actions (e.g., as in Gandalf
), or
declaratively by an
attribute grammar
An attribute grammar is a formal way to supplement a formal grammar with semantic information processing. Semantic information is stored in attributes associated with terminal and nonterminal symbols of the grammar. The values of attributes are t ...
(e.g., as in the Synthesizer Generator
) or by unification in a many-sorted algebra (e.g., as in PSG
) or a
logic program
Logic programming is a programming, database and knowledge representation paradigm based on formal logic. A logic program is a set of sentences in logical form, representing knowledge about some problem domain. Computation is performed by applyin ...
(e.g., as in Centaur
and Pan
), with compliance checked by the underlying editing machinery. Structured editors vary in the degree to which they allow their users to perform edits that cause the document to become syntactically or semantically incorrect.
It is common for a language sensitive editor to represent a document as a
parse tree
A parse tree or parsing tree (also known as a 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 use ...
with respect to language's grammar, or as an
abstract syntax tree
An abstract syntax tree (AST) is a data structure used in computer science to represent the structure of a program or code snippet. It is a tree representation of the abstract syntactic structure of text (often source code) written in a formal ...
(AST). For example, a
DOM tree is essentially an AST with respect to a given
DTD. Frequently, the textual view of that underlying tree is generated by
prettyprinting the underlying tree. Editors associated with intentional programming
and
language-oriented programming Language-oriented programming (LOP) is a software-development paradigm where "language" is a software building block with the same status as objects, modules and components, and rather than solving problems in general-purpose programming languages, ...
for
general-purpose languages and
domain-specific languages share many of the features of language-sensitive editors, but aim for greater separation between the underlying representation (the
intention
An intention is a mental state in which a person commits themselves to a course of action. Having the plan to visit the zoo tomorrow is an example of an intention. The action plan is the ''content'' of the intention while the commitment is the ...
) and the surface representation (text in a programming language).
Examples
*
JetBrains MPS
JetBrains MPS (Meta Programming System) is a language workbench developed by JetBrains. MPS is a tool to design domain-specific languages (DSL). It uses projectional editing which allows users to overcome the limits of language parsers, and bui ...
*
Lapis (text editor): Editing Text with Lightweight Structure
See also
*
Source code editor
A source-code editor is a text editor program designed specifically for editing source code of computer programs. It may be a standalone application or it may be built into an integrated development environment (IDE).
Features
Source-code editor ...
*
Source Code in Database
*
Homoiconicity
In computer programming, homoiconicity (from the Greek words ''homo-'' meaning "the same" and ''icon'' meaning "representation") is an informal property of some programming languages. A language is homoiconic if a program written in it can be mani ...
References
{{Reflist
Text editor features