Syntax Driven Editors
There are three kinds of editors for programming languages:
- Most general purpose editors are totally unaware of the
syntax of the language a file is written in.
The only way to verify the syntax is to compile the program.
- A syntax-aware editor (also called syntax-savvy editor)
scans the source file for syntax
elements while the user enters program text.
Syntax elements that are recognized are visibly marked.
Automatic (left) indentation and matching parentheses is also helpful.
Marking recognized elements helps users in finding syntax errors early on.
When a keyword is not marked, or a line not indented correctly,
it means that there is a (recently introduced) syntax error which upsets
the syntax recognizer.
- A syntax-driven editor generates source files from a grammar.
The user cannot enter text which is syntactically incorrect.
Language constructs are often entered through dialog boxes.
Using syntax-driven editors is often cumbersome.
You cannot simply type x = y + 1; because while typing
the syntax would be incorrect.
So you have to perform an action that pops up an "assignment" dialog box,
in which you can enter the left and right operand.
For the right operand you may have to open another dialog box to enter
the addition-expression.
Syntax-driven editors are most useful for non-programming languages,
for applications which do not require the user to know the underlying
language. Examples are HTML editors and document processing systems such as
MS-Word and WordPerfect.
A syntax-savvy or syntax-driven editor does not guarantee that programs you
write with it will compile without errors.
In order to provide this guarantee the editor must also know all
context-sensitive aspects of the languages, like scope rules,
and rules about where which language constructs are or are not allowed.
Syntax-driven editors for document processing are better at generating
syntactically correct files than those for programming languages.
Some syntax-savvy editors are able to interpret compiler error messages
and point to the lines in the source code where the compiler detects errors.