To use LSE to create or edit source code requires an understanding of
the concepts of tokens and placeholders. Tokens and placeholders are
language elements that have been predefined for each of the supported
languages. These elements can be expanded into templates for
language constructs.
Placeholders
Placeholders are markers in the source code that indicate locations
where you can provide program text. These placeholders help you to
supply the appropriate syntax in a given context. Generally, you do
not need to type placeholders, rather, they are inserted for you by
LSE. Placeholders can be recognized because they are surrounded by
brackets or braces. The exact choice for placeholder brackets is
language dependent.
There are three types of placeholders:
o Terminal placeholders
o Nonterminal placeholders
o Menu placeholders
Terminal placeholders provide text strings that describe valid
replacements for the placeholder. Nonterminal placeholders expand
into additional language constructs. Menu placeholders provide a
list of options corresponding to the placeholder. The type of a
placeholder is a property of the placeholder name.
Placeholders are either optional or required. Required placeholders,
indicated by braces, represent places in the source code where you
must provide program text. Optional placeholders, indicated by
brackets, represent places in the source code where you can either
provide additional constructs or erase the placeholder.
For example, the declaration
INTEGER {identifier}...
when expanded becomes
INTEGER id,
[identifier]...
The first appearance of the identifier placeholder is surrounded by
braces because you need at least one identifier in this declaration.
The second appearance is surrounded by brackets because additional
identifiers are optional.
Some placeholders are duplicated when expanded. These placeholders
are followed by an ellipsis. Generally, these placeholders represent
items such as identifiers, statements, expressions, datatypes, or any
location where lists of items are expected. A placeholder is
duplicated either vertically or horizontally, depending on the
context and the placeholder definition. For example, the placeholder
[identifier] in the previous example was duplicated vertically.
You may move forward or backward from placeholder to placeholder. In
addition, you can delete or expand placeholders as needed. LSE
allows you to specify uppercase, lowercase, or as defined for all
text expanded into the buffer.
You may modify placeholder definitions by means of the EXTRACT
command. See Chapter 6 for information on modifying placeholders.
Placeholder definitions may be stored in an environment file. See
Chapter 7 for information on defining your own placeholders.
TOKENS
Tokens are typically keywords in programming languages. When
expanded, tokens provide additional language constructs. Tokens are
typed directly into the buffer. Generally, tokens are used in
situations when you want to add additional language constructs where
there are no placeholders. For example, typing IF and pressing the
EXPAND key causes a template for an IF construct to appear on your
screen. Tokens are also used to bypass long menus in situations
where expanding a placeholder, such as {statement}, would result in a
lengthy menu.
You can use tokens to insert text when editing an existing file.
Because most languages have tokens for built-in functions and
keywords, you type the name for a function or keyword and press the
EXPAND key. In addition, most languages provide a token named
'statement' or 'expression' that expands into a menu of all possible
statements or expressions.
The following example demonstrates how to use tokens to edit an
existing program. In this case, the buffer, TEST.EXAMPLE, contains
the following code:
PROCEDURE test ()
IF A = B
THEN
A = C + 1
ENDIF
ENDPROCEDURE test
If you want to add more statements to this program before the IF
construct, do the following:
1. Move the cursor to the beginning of the IF procedure line.
2. Press the OPEN LINE key (PF1-KP0).
3. Press the TAB key.
Note that the cursor is placed at the same level of indentation
as the next line.
4. Type statement and press the EXPAND key.
A menu of statements will now appear on your screen. You use the
arrow keys to scroll through the menu. To select a menu item, you
press the EXPAND, ENTER, or RETURN key. You can press the space bar
to exit a menu without selecting an item.
Additional Information:
explode
extract