com.ibm.lpex.hlasm
Class HLAsmParser
java.lang.Object
com.ibm.lpex.core.LpexCommonParser
com.ibm.lpex.hlasm.HLAsmParser
- All Implemented Interfaces:
- LpexConstants, LpexParser
- Direct Known Subclasses:
- TPFHLAsmParser
- public class HLAsmParser
- extends LpexCommonParser
Document parser for HLASM (High Level Assembler).
Actions added by this document parser for selective views of the document:
- asmInstructions - assembler instructions
- branches - branch instructions and labels
- errors - errors
- comments - comments.
Commands added by this document parser to query and set parser properties:
- queryBranchColoring - query state of branch coloring
- setBranchColoring - turn branch coloring on/off;
the advantage of turning it off is performance
- queryCustomColoring - query state of custom instruction coloring
- setCustomColoring - turn custom instruction coloring on/off
- queryCustomColorFile - query the path of the custom color XML file
- setCustomColorFile - set the path of an XML file conforming to the
hlasm_definition.dtd that associates colors to instructions
- queryCaseLevel - query the case level
- setCaseLevel - set the case strictness to one of the three supported levels:
ALL_CASE, NO_CASE, DEFAULT_CASE.
Fields inherited from class com.ibm.lpex.core.LpexCommonParser |
ATTRIBUTES_COMMENT, ATTRIBUTES_COMMENT_KEYWORD, ATTRIBUTES_COMMENT1, ATTRIBUTES_DEFAULT, ATTRIBUTES_DIRECTIVE, ATTRIBUTES_ERROR, ATTRIBUTES_KEYWORD, ATTRIBUTES_KEYWORD1, ATTRIBUTES_LIBRARY, ATTRIBUTES_NONSOURCE, ATTRIBUTES_NUMERAL, ATTRIBUTES_STRING, ATTRIBUTES_STRING1, BACKGROUND_COLOR, CLASS_MESSAGE, LANGUAGE_CCPP, LANGUAGE_CICS, LANGUAGE_CL, LANGUAGE_COBOL, LANGUAGE_DDS, LANGUAGE_FORTRAN, LANGUAGE_HLASM, LANGUAGE_HTML, LANGUAGE_JAVA, LANGUAGE_JCL, LANGUAGE_LISP, LANGUAGE_PERL, LANGUAGE_PLI, LANGUAGE_REXX, LANGUAGE_RPG, LANGUAGE_SABRETALK, LANGUAGE_SQL, LANGUAGE_XMI, LANGUAGE_XML, LANGUAGE_XSL, LEXER_RC_END, LEXER_RC_EOF, LEXER_RC_MORE, LEXER_RC_OK, POPUP_END, POPUP_FILTERVIEW, POPUP_SOURCE, POPUP_TOP, PROTOKEY_EMPTY, STYLE_MESSAGE, STYLE_NAME, view
|
Fields inherited from interface com.ibm.lpex.core.LpexConstants |
HELP_COMMAND_MAP, LPEX_VERSION, MSG_POPUP_ERRORS, MSG_POPUP_EXCLUDESELECTION, MSG_POPUP_FILTERVIEWMENU, MSG_POPUP_INSERTMENU, MSG_POPUP_SELECTEDMENU, MSG_POPUP_SHOWALL, MSG_POPUP_SOURCEMENU, PARSE_PENDING_CHANGE_MASK, PARSE_PENDING_NEXT_DELETED_MASK, PARSE_PENDING_NEXT_SHOW_DELETED_MASK, PARSE_PENDING_PREV_DELETED_MASK, PARSE_PENDING_PREV_SHOW_DELETED_MASK, PLATFORM_AWT, PLATFORM_SWT, PLATFORM_SWT_KEY, STATUS_FILE_ERRORREADING, STATUS_FILE_INCORRECTENCODING, STATUS_FILE_NOTFOUND, STATUS_FINDTEXT_INVALIDPATTERN, STATUS_FINDTEXT_NOTFOUND, STATUS_FINDTEXT_ONLYOCCURRENCE, STATUS_FINDTEXT_READONLY, STATUS_FINDTEXT_WRAPPED, STATUS_LOCATE_NOSEQUENCETEXT, STATUS_LOCATE_NOTFOUND, STATUS_LOCATE_WRAPPED, STATUS_SAVE_CANCELLED, STATUS_SAVE_FAILED, STATUS_TEXTLIMIT_ENFORCED
|
Method Summary |
void
| clearInstructionTable()
Removes all the instructions from the
static instruction table.
|
String
| convertCaseToString(int level)
|
protected void
| createInstruction(int type,
String lineX)
This method is called when the instruction table is created.
|
boolean
| getBranchColoring()
|
String
| getBranchColoringString()
|
int
| getCaseSensitivityLevel()
|
String
| getCaseSensitivityLevelString()
|
String
| getCommentStyleCharacters()
Returns the style characters used for styling comments and remarks ("cr").
|
static InstrColorAssoc
| getCustomColorAssociations()
|
static String
| getCustomColorFileLocation()
|
protected IFileLocator
| getFileLocator()
Returns the file locator being used by this HLASM parser.
|
String
| getInitialCommands()
|
boolean
| getInstructionColoring()
|
String
| getInstructionColoringString()
|
protected static char
| getInstructionsSpecialColor(String name)
When parsing a file, this method can be used to see if
there has been a custom color set for the instruction.
|
String
| getLanguage()
Returns "HLASM" as the language supported by the HLASM and
TPF HLASM document parsers.
|
static char
| getNextValidColorChar()
Returns the next character that can be used to define a custom color.
|
String
| getParserPropertiesFileName()
Returns the HLASM parser profile name.
|
protected String
| getPopupItems(int popupLocation)
Returns this parser's contribution to the pop-up menu.
|
ResourceBundle
| getProfile()
Returns the document parser's profile resource bundle.
|
String
| getPropertyDefault(String key)
This method will get the default value for the given key.
|
protected int
| getTypeOfTag(String tag)
This method is called when the instruction table is being loaded.
|
protected void
| loadCustomInstructionColors(String xml_file,
boolean reload)
Load a user XML file containing custom color settings.
|
void
| loadInstrTable()
Loads the static table(s) of supported instructions, registers, etc.
|
String
| nextInstruction()
Retrieve the next instruction-format line.
|
void
| parseAll()
Total parse of the entire document.
|
protected void
| parseAllOpenFiles()
Reparses all open views of HLASM parser files.
|
void
| parseElement(int changedElement)
Incremental parse.
|
void
| performReParse()
When variables change that will affect how the current
document is parsed, a reparse should be performed.
|
protected static void
| resetColorCharacters()
Resets the valid color character counter.
|
protected static String
| retrieveMessage(String key,
String sub)
Retrieves a message with an optional substitution argument.
|
void
| setBranchColoring(boolean state_on,
boolean update,
boolean re_parse)
If the state has changed this method will make the required adjustements.
|
void
| setBranchColoringString(String state,
boolean update,
boolean re_parse)
The method can be used to change the state of the branch coloring
feature.
|
void
| setCaseSensitivityLevel(int i_case_level,
boolean update,
boolean re_parse)
|
void
| setCaseSensitivityLevelString(String s_case_level,
boolean update,
boolean re_parse)
The case level is a file-scoped variable.
|
void
| setCustomColorFileLocation(String fileName,
boolean color_file_updated,
boolean update,
boolean re_parse)
This method is used to set the location of the user provided XML file.
|
protected void
| setDefaultPreferences()
Retrieves parser properties from the storage location and uses those
defaults to set initial parser values.
|
static void
| setFileLocator(IFileLocator fileLocator)
Sets a file locator for the HLASM parsers.
|
void
| setInitialCommands(String command_string,
boolean update,
boolean reparse)
The initial commands is a set of commands that should be run
each time a file using this parser is opened.
|
void
| setInstructionColoring(boolean state_on,
boolean update,
boolean re_parse)
This method is used to turn the special instruction coloring feature on
and off.
|
void
| setInstructionColoringString(String state,
boolean update,
boolean re_parse)
This method is used to turn the special instruction coloring feature on and
off.
|
void
| setStyleAttributes()
Defines parser's style attributes.
|
void
| terminateParser()
The parser is terminated.
|
Methods inherited from class com.ibm.lpex.core.LpexCommonParser |
addMessage, addMessage, addMessage, blockMarkWord, cursorIndent, expandProtoKeyword, getInstallStyleAttributes, getLanguage, getLshToken, getPopupParserItems, getPopupViewItems, getProperty, getStyleName, getStyles, getTextIndent, getToken, getTokenLocation, indentText, indentText, indentText, isDebuggable, isTokenDelimiter, lineComment, lpexView, matchToken, newLine, openLine, parse, removeMessages, removeMessages, resetParser, setProperty, setStyle, splitLine, styleString, tokenBegin, tokenEnd, totalParse
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
|
classContinue
protected long classContinue
classForwardLink
protected long classForwardLink
classBackwardLink
protected long classBackwardLink
classCode
protected long classCode
classComment
protected long classComment
classError
protected long classError
classSequence
protected long classSequence
classQString
protected long classQString
classRemark
protected long classRemark
classOperand
protected long classOperand
classPendingOp
protected long classPendingOp
classOperLine
protected long classOperLine
classMachineIns
protected long classMachineIns
classAssemIns
protected long classAssemIns
classLabel
protected long classLabel
classBranch
protected long classBranch
classUnknown
protected long classUnknown
classAsmMacroB
protected long classAsmMacroB
classAsmMacroE
protected long classAsmMacroE
classAsmMacroN
protected long classAsmMacroN
classMacroCall
protected long classMacroCall
classAll
protected long classAll
loaded_instructions
protected static OrderedInstructionList loaded_instructions
userMacrosRead
protected static boolean userMacrosRead
userReader
protected static BufferedReader userReader
ITYPE_UNDEFINED
protected static final int ITYPE_UNDEFINED
- See Also:
- Constant Field Values
ITYPE_MACHINE
protected static final int ITYPE_MACHINE
- See Also:
- Constant Field Values
ITYPE_ASSEMBLER
protected static final int ITYPE_ASSEMBLER
- See Also:
- Constant Field Values
ITYPE_SPECIALS
protected static final int ITYPE_SPECIALS
- See Also:
- Constant Field Values
ITYPE_REGISTERS
protected static final int ITYPE_REGISTERS
- See Also:
- Constant Field Values
ITYPE_ATTRIBUTES
protected static final int ITYPE_ATTRIBUTES
- See Also:
- Constant Field Values
ITYPE_USER
protected static final int ITYPE_USER
- See Also:
- Constant Field Values
HLAsmParser
public HLAsmParser(LpexView lpexView)
- Constructor.
- Parameters:
- lpexView - the LPEX document view associated with this parser
terminateParser
public void terminateParser()
- The parser is terminated. Either the document view is being disposed,
or the parser is being (temporarily) disposed during the processing
of the updateProfile command.
When the parser is being disposed, we remove it from the global list
of HLASM parsers. This list is maintained so that when a global
property is changed, all parser instances can be updated to reflect the
changes.
- Overrides:
- terminateParser in class LpexCommonParser
setDefaultPreferences
protected void setDefaultPreferences()
- Retrieves parser properties from the storage location and uses those
defaults to set initial parser values.
The user can change these values by:
- Calling Commands - There are editor commands available to change
the values of the setting. When a call is made, and the value is document
specific, the value is changed for the current session and current document only.
If the value is a global variable, the change will be stored to the properites
file and used for all documents
- Preference Pages - An editor application that uses this parser may also
use custom preference pages to set the values.
loadCustomInstructionColors
protected void loadCustomInstructionColors(String xml_file,
boolean reload)
- Load a user XML file containing custom color settings.
The settings are used to color HLASM instructions with a particular color.
This feature can be turned on and off for each document.
- Parameters:
- xml_file - the name and path of the XML file
containing the color associations
- reload - true = you are reloading the file; or
false = you are just checking whether it needs to be
loaded, or loading for the first time
getProfile
public ResourceBundle getProfile()
- Returns the document parser's profile resource bundle.
- Overrides:
- getProfile in class LpexCommonParser
- See Also:
- LpexCommonParser.getProperty(java.lang.String),
Parser properties
getParserPropertiesFileName
public String getParserPropertiesFileName()
- Returns the HLASM parser profile name.
performReParse
public void performReParse()
- When variables change that will affect how the current
document is parsed, a reparse should be performed.
getLanguage
public String getLanguage()
- Returns "HLASM" as the language supported by the HLASM and
TPF HLASM document parsers.
- Overrides:
- getLanguage in class LpexCommonParser
- See Also:
- LpexCommonParser.LANGUAGE_HLASM
retrieveMessage
protected static String retrieveMessage(String key,
String sub)
- Retrieves a message with an optional substitution argument.
This method uses LpexResources.
- Parameters:
- key - the key of the message in the parser profile
- sub - a substitution variable to insert into the string, or
null if none
- Returns:
- a string containing the retrieved message, or an empty
string if the message could not be found
getPopupItems
protected String getPopupItems(int popupLocation)
- Returns this parser's contribution to the pop-up menu.
This parser contributes to the "Filter view" submenu (Assembler instructions,
Branch instructions and labels, Comments, Errors).
- Overrides:
- getPopupItems in class LpexCommonParser
- Parameters:
- popupLocation - the location on the popup menu of the items
requested, one of:
LpexCommonParser.POPUP_TOP, LpexCommonParser.POPUP_FILTERVIEW,
LpexCommonParser.POPUP_SOURCE, LpexCommonParser.POPUP_END
- Returns:
- this parser's contribution to the popup menu, or
null if none
setStyleAttributes
public void setStyleAttributes()
- Defines parser's style attributes.
The following style characters are set:
'_' (layout blanks),
'z' (default text),
't' (special symbol/character),
'c' (line comment),
'r' (statement remark),
'x' (error),
'n' (single-quoted string),
'p' (statement name/label),
'v' (sequence information),
'q' (machine instruction),
'a' (assembler instruction),
'w' (continuation character).
getCommentStyleCharacters
public String getCommentStyleCharacters()
- Returns the style characters used for styling comments and remarks ("cr").
This is used by compare sessions when the compare.ignoreComments
option is in effect.
- Overrides:
- getCommentStyleCharacters in class LpexCommonParser
parseAll
public void parseAll()
- Total parse of the entire document.
- Specified by:
- parseAll in class LpexCommonParser
- See Also:
- Total and incremental parse
parseElement
public void parseElement(int changedElement)
- Incremental parse.
- Specified by:
- parseElement in class LpexCommonParser
- Parameters:
- changedElement - an element whose committed change triggered the parse,
or the element that precedes / follows a deleted block.
The parser may identify other neighbouring elements that
will have to be reparsed as a unit
- See Also:
- LpexView.parsePending(int),
LpexView.elementParsed(int),
Total and incremental parse
loadInstrTable
public void loadInstrTable()
- Loads the static table(s) of supported instructions, registers, etc.
clearInstructionTable
public void clearInstructionTable()
- Removes all the instructions from the
static instruction table. This is neccessary if the user
changes the custom macro file. The entire table is reloaded
because there is no separation between user macros and coded
macros. For performance reasons, this action should not be called frequently.
getTypeOfTag
protected int getTypeOfTag(String tag)
- This method is called when the instruction table is being loaded.
This method may be extended by subclasses in order to allow more types.
- Parameters:
- tag - a tag found in a data file (user or hard coded),
e.g., "[MACHINE]"
- Returns:
- a valid type if a match for the tag string is found; or
null to indicate no match was found
createInstruction
protected void createInstruction(int type,
String lineX)
- This method is called when the instruction table is created.
The method may be extended by subclasses to support additional instruction types.
- Parameters:
- type -
- lineX -
nextInstruction
public String nextInstruction()
- Retrieve the next instruction-format line.
This method is being called repeatedly to set up the parser's instructions
table, until it returns null.
The method can be extended by a subclassing parser to add custom
macros/instructions.
parseAllOpenFiles
protected void parseAllOpenFiles()
- Reparses all open views of HLASM parser files.
This method can be used when parser properties have changed. For example,
if branch coloring is toggled, the files must be reparsed to pick up the
changes.
getNextValidColorChar
public static char getNextValidColorChar()
- Returns the next character that can be used to define a custom color.
Some of the characters are already in use by the parser. There is a maximum
of 14 valid characters. Once the maximum is reached, no more custom colors
can be defined.
- Returns:
- a valid character to use as a style character, or
a space (' ') if there are no more characters
resetColorCharacters
protected static void resetColorCharacters()
- Resets the valid color character counter.
This should be done if the custom file is being reloaded
otherwise the characters will pick-up where they left off and
might run out of color characters (there are only a limited number
that can be used).
getInstructionsSpecialColor
protected static char getInstructionsSpecialColor(String name)
- When parsing a file, this method can be used to see if
there has been a custom color set for the instruction.
- Parameters:
- name - the name of the instruction in question
- Returns:
- if a color exists for this instruction, the character is returned;
if the instruction does not have a color, space (' ') is returned
setCaseSensitivityLevelString
public void setCaseSensitivityLevelString(String s_case_level,
boolean update,
boolean re_parse)
- The case level is a file-scoped variable. The setting will not be stored in
the properties file. It will only be persisted for the current session. It is possible
to change this setting on the fly once the document is already open, however it will be slow
because a re-parse is needed.
- Parameters:
- s_case_level - the case level must be one of three values:
- ALL_CASE - The most sensitive level. Anything that is not
specified in lower case in the data file must be specified in the same case.
- NO_CASE - The least sensitive level. Nothing is case sensitive.
- DEFAULT_CASE - The middle level. This is the default level of the assembler.
If the value given is not ALL_CASE or NO_CASE, DEFAULT_CASE is used.
When using DEFAULT_CASE, Positional operands must be the correct case and also
text afer the '=' in a keyword must be correct case.
-
- update - changes should be made so they take effect immediately.
There are currently no "update" specific functions for the case level change.
- re_parse - should a reparse, if required, be performed now.
The reparse will be needed before changes take effect, however if there
are multiple changes being made then set update to true and reparse to
false and then reparse later
setCaseSensitivityLevel
public void setCaseSensitivityLevel(int i_case_level,
boolean update,
boolean re_parse)
- Parameters:
- i_case_level - the new case level
- update - changes should be made so they take effect immediately.
There are currently no "update" specific functions for the case level change.
- re_parse - should a reparse, if required, be performed now.
The reparse will be needed before changes take effect, however if there
are multiple changes being made then set update to true and reparse to
false and then reparse later
- See Also:
- setCaseSensitivityLevelString(java.lang.String, boolean, boolean)
getCaseSensitivityLevelString
public String getCaseSensitivityLevelString()
getCaseSensitivityLevel
public int getCaseSensitivityLevel()
setBranchColoringString
public void setBranchColoringString(String state,
boolean update,
boolean re_parse)
- The method can be used to change the state of the branch coloring
feature. The branch coloring feature will color invalid labels red.
The advantage of turning the feature off is speed.
- Parameters:
- state - TRUE - The branch color feature will either be turned on or
remain on. If the feature was previously off the document will be parsed
so that any existing invalid labels are colored red.
FALSE - The branch color feature will either be turned off or remain off.
The document will be parsed so that any invalid labels will not be colored red.- update - - The update variable indicates that changes should be made so the
changes can be made immediatly. When the branch feature state changes, updates include
re-builing / clearing the label table.
- re_parse - - If a re-parse is required, this variable will be checked to see
if it should be performed now. The re-parse will be needed before changes take effect
however if there are multiple changes being made then set update to true and reparse to
false and then re-parse later.
setBranchColoring
public void setBranchColoring(boolean state_on,
boolean update,
boolean re_parse)
- If the state has changed this method will make the required adjustements.
- Parameters:
- state_on - - A boolean indicating the new state for the variable.
- update - - The update variable indicates that changes should be made so the
changes can be made immediatly. When the branch feature state changes, updates include
re-builing / clearing the label table.
- re_parse - - If a re-parse is required, this variable will be checked to see
if it should be performed now. The re-parse will be needed before changes take effect
however if there are multiple changes being made then set update to true and reparse to
false and then re-parse later.
- See Also:
- setBranchColoringString(java.lang.String, boolean, boolean)
getBranchColoringString
public String getBranchColoringString()
getBranchColoring
public boolean getBranchColoring()
setInstructionColoringString
public void setInstructionColoringString(String state,
boolean update,
boolean re_parse)
- This method is used to turn the special instruction coloring feature on and
off. The user associates insturctions with colors in an xml file. If this
feature is on, that file will be used and the instructions they associate are
colored with the special color rather than the default color.
- Parameters:
- state - "on" = turn the feature on - if the feature was previously off, a reparse is
performed; or
"off" = turn the feature off - if the feature was previously on, a reparse
is used to un-color any colored labels
- update - the update variable indicates that changes should be made so the
changes can be made immediatly. Updates for the instruction color state changes
will include re-loading the custom color file
- re_parse - if a reparse is required, this variable will be checked to see
if it should be performed now. The re-parse will be needed before changes take effect
however if there are multiple changes being made then set update to true and reparse to
false and then reparse later
setInstructionColoring
public void setInstructionColoring(boolean state_on,
boolean update,
boolean re_parse)
- This method is used to turn the special instruction coloring feature on
and off. The user associates instructions with colors in an XML file.
If this feature is on, that file will be used, and the instructions they
associate are colored with the special color rather than the default color.
- Parameters:
- state_on - true = turn the feature on. If the feature was previously off,
a reparse is performed;
false = turn the feature off. If the feature was previously on,
a reparse is done to uncolor any colored labels.
- update - changes should be made so the changes become effective
immediately. Updates for the instruction color state changes
will include reloading the custom color file.
- re_parse - if a reparse is required, this argument is checked to see
if it should be performed now. The reparse will be needed before
changes take effect, however if there are multiple changes being
made then set update to true and reparse to false, and then
reparse later.
getInstructionColoringString
public String getInstructionColoringString()
getInstructionColoring
public boolean getInstructionColoring()
setCustomColorFileLocation
public void setCustomColorFileLocation(String fileName,
boolean color_file_updated,
boolean update,
boolean re_parse)
- This method is used to set the location of the user provided XML file. The
XML file must contain associations between instructions and colors. The file
is used to color the special instructions in the associated colors. The setting
for this variable will be stored to the properties file and persited between sessions.
- Parameters:
- fileName - the name of the XML file containing color definitions.
If the coloring feature is currently on, changing the color file will
cause a reparse with the new colors in the newly provided file
- color_file_updated - if the content of the file has changed and needs
to be refreshed, this variable should be true, otherwise the file will
only be loaded if the name has changed
- update - when the location of the color file changes the instruction table
needs to be changed to use the new colors. If update is true this
update to static parser variables will be made. Otherwise the change
is saved to the .properties file but has no affect on any files.
- re_parse - if the color file has been reread then the document should be
reparsed. Because the file location is a global setting. All documents
should be reparsed to pick up the new setting. If this variable is true,
all documents including this one will be reparsed when it is needed. If it
is false, no documents are reparsed
getCustomColorFileLocation
public static String getCustomColorFileLocation()
getCustomColorAssociations
public static InstrColorAssoc getCustomColorAssociations()
setInitialCommands
public void setInitialCommands(String command_string,
boolean update,
boolean reparse)
- The initial commands is a set of commands that should be run
each time a file using this parser is opened.
- Parameters:
- command_string - a string of commands to be stored in the .properties
file where each command is separated by ";" (semicolon)
- update - if true, the commands will be issued now, otherwise the commands
are saved but not isssued; when the commands are issued,
they will be issued to all open parsers
- reparse - ignored
getInitialCommands
public String getInitialCommands()
setFileLocator
public static void setFileLocator(IFileLocator fileLocator)
- Sets a file locator for the HLASM parsers.
- See Also:
- getFileLocator()
getFileLocator
protected IFileLocator getFileLocator()
- Returns the file locator being used by this HLASM parser.
If no global file locator was previously set, a default file locator is set
and returned.
- See Also:
- setFileLocator(IFileLocator)
getPropertyDefault
public String getPropertyDefault(String key)
- This method will get the default value for the given key. This
method is different from getProperty because even if a custom setting
has been made the default is returned from this method.
- Parameters:
- key - the idendifier for the value to be retrieved
- Returns:
- the default value of the given key, or null if
the key has no default value
convertCaseToString
public String convertCaseToString(int level)