LPEX
4.4.0

com.ibm.lpex.pli
Class PliParser

java.lang.Object
  extended by com.ibm.lpex.core.LpexCommonParser
      extended by com.ibm.lpex.pli.PliParser
All Implemented Interfaces:
LpexConstants, LpexParser

public class PliParser
extends LpexCommonParser

Document parser for PL/I.

Actions added by this document parser for selective views of the document:

Keys already defined (for example, by the active base editor profile and by the user profile) to an action different from nullAction are not redefined in here.

Editor actions modified by this document parser:

Parser properties handled directly by this parser:


Nested Class Summary
static class PliParser.Keyword
          PL/I keyword information.
 
Field Summary
protected  long _classAll
          Element-classes aggregate.
protected static int LEXER_CICS
           
protected static int LEXER_DLI
           
protected static int LEXER_OWNER
           
protected static int LEXER_PLI
           
protected static int LEXER_SQL
           
 
Fields inherited from class com.ibm.lpex.core.LpexCommonParser
ATTRIBUTES_COMMENT, ATTRIBUTES_COMMENT_KEYWORD, ATTRIBUTES_COMMENT1, ATTRIBUTES_DEFAULT, ATTRIBUTES_DIRECTIVE, ATTRIBUTES_ERROR, ATTRIBUTES_ERROR1, 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_COBOL400, LANGUAGE_COBOLILE, LANGUAGE_DDS, LANGUAGE_DLI, LANGUAGE_FORTRAN, LANGUAGE_HLASM, LANGUAGE_HTML, LANGUAGE_JAVA, LANGUAGE_JCL, LANGUAGE_LISP, LANGUAGE_PERL, LANGUAGE_PLI, LANGUAGE_REXX, LANGUAGE_RPG, LANGUAGE_RPGLEFIXED, LANGUAGE_RPGLEFREE, 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_COMMENT, MSG_POPUP_ERRORS, MSG_POPUP_EXCLUDESELECTION, MSG_POPUP_FILTERVIEWMENU, MSG_POPUP_INSERTMENU, MSG_POPUP_SELECTEDMENU, MSG_POPUP_SHOWALL, MSG_POPUP_SOURCEMENU, MSG_POPUP_TASKS, MSG_POPUP_UNCOMMENT, PARSE_PENDING_CHANGE_MASK, PARSE_PENDING_INSERT_MASK, PARSE_PENDING_NEXT_DELETED_MASK, PARSE_PENDING_NEXT_SHOW_DELETED_MASK, PARSE_PENDING_PREV_DELETED_MASK, PARSE_PENDING_PREV_SHOW_DELETED_MASK, PARSE_PENDING_UNDO_MASK, PLATFORM_AWT, PLATFORM_SWT, PLATFORM_SWT_KEY, SHOW_ALL, SHOW_DOCUMENT, SHOW_NONE, SHOW_VIEW, STATUS_FIELDS_NOINSERT, STATUS_FIELDS_TRUNCATE, 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, STATUS_TEXTLIMIT_OVERFLOW, STATUS_UNDO_NOTHINGUNDONE
 
Constructor Summary
PliParser(LpexView lpexView)
          Constructor.
 
Method Summary
protected  void backSpace()
          Override the default backspace behaviour.
 String[] compileOptionKeywords()
          Returns a list of the compile-time options defined in this parser.
protected  void delete()
          Override the default delete behaviour.
 String getCommentStyleCharacters()
          Returns the style characters used for styling comments ("c$").
 String getLanguage()
          Returns "PLI", the language supported by this parser (PL/I).
 String getLanguage(LpexDocumentLocation loc)
          Returns a string identifying the language segment at the specified location.
 int getLeftMargin()
          Returns the left margin used to parse the document.
protected  LpexSubparser getLexer(int lexer, LpexCharStream lexerStream)
          Returns the specified subparser.
 String getLshToken()
          Returns the current token for language-sensitive help (LSH).
 String getNamesCharacters()
          Returns the extra characters for names used in the parsing of this document.
 String getNotCharacters()
          Returns the characters for the logical NOT operator used in the parsing of this document.
 String getOrCharacters()
          Returns the characters for the logical OR operator used in the parsing of this document.
protected  String getPopupItem(String key)
           
protected  String getPopupItems(int popupLocation)
          Returns this parser's contribution to the popup.
 ResourceBundle getProfile()
          Returns this parser's profile resource bundle.
 String getProperty(String key)
          Extends LpexCommonParser's getProperty() to substitute the arguments for key PROTOKEY_EMPTY.
 int getRightMargin()
          Returns the right margin used to parse the document.
protected  LpexCharStream getStream()
          Returns the character stream used by the parser.
protected  boolean hasOwnerSubparser()
          Returns the availability of an owner subparser.
protected  void initParser()
          Initializes the parser.
protected  PliParser.Keyword isKeyword(Token token)
          Returns whether the given token is a non compile-option PL/I keyword.
protected  PliParser.Keyword isKeyword(Token token, int attribute)
          Returns whether the given token is a PL/I keyword of a particular attribute.
protected  boolean isOwnerElement(int element)
          Returns whether the specified text element should be parsed by the custom lexer (LEXER_OWNER).
 boolean isTokenDelimiter(char ch)
          Returns whether the specified character is a token delimiter.
protected  int join()
          Override the default join behaviour.
protected  int join(boolean undoCheck)
          Override the default join behaviour.
 String[] keywords()
          Returns a list of the PL/I keywords defined in this parser.
protected  LpexDocumentLocation matchToken(LpexDocumentLocation loc)
          Matches PL/I constructs (e.g., "PROC" - "END").
protected  String nextKeyword()
          Retrieves the next keyword-definition line.
 void parseAll()
          Total parse of the entire document.
 void parseElement(int element)
          Incremental parse.
protected  void propertySet(String key)
          Listens to changes to the taskTags parser property in this view.
protected  void setLineStructure()
          (Re)sets the format line and the editing fields for the left and right margins in effect.
 void setStyleAttributes()
          Defines parser's style attributes.
protected  void splitLine()
          Override the default splitLine behaviour.
protected  void splitLine(boolean undoCheck)
          Override the default splitLine behaviour.
protected  void terminateParser()
          Cleans up any resources allocated by this parser.
 
Methods inherited from class com.ibm.lpex.core.LpexCommonParser
addDocumentMessage, addMessage, addMessage, addMessage, blockMarkWord, copyDocumentMessages, cursorIndent, defineFilterAction, defineFilterAction, expandProtoKeyword, getInstallStyleAttributes, getStyleName, getStyles, getTextIndent, getToken, getTokenLocation, indentText, indentText, indentText, isDebuggable, isPrimaryParser, isWordCharacter, lineComment, lpexView, newLine, openLine, parse, removeDocumentMessages, removeMessages, removeMessages, resetParser, setProperty, setStyle, styleString, tokenBegin, tokenEnd, totalParse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_classAll

protected long _classAll
Element-classes aggregate.


LEXER_PLI

protected static final int LEXER_PLI
See Also:
Constant Field Values

LEXER_SQL

protected static final int LEXER_SQL
See Also:
Constant Field Values

LEXER_CICS

protected static final int LEXER_CICS
See Also:
Constant Field Values

LEXER_DLI

protected static final int LEXER_DLI
See Also:
Constant Field Values

LEXER_OWNER

protected static final int LEXER_OWNER
See Also:
Constant Field Values
Constructor Detail

PliParser

public PliParser(LpexView lpexView)
Constructor.

Parameters:
lpexView - the LPEX document view associated with this parser
Method Detail

initParser

protected void initParser()
Initializes the parser. Sets up the parser for the associated document view: sets style attributes, registers element classes, creates editor actions, redefines the popup, etc. for the language-sensitive edit features supported.

Overrides:
initParser in class LpexCommonParser
See Also:
Life cycle

splitLine

protected void splitLine()
Override the default splitLine behaviour. When text is split, indent it to the level of the previous line plus specific indent length (default indent length is 2, data hierarchies space is 2), No special handling for comments and literals.

Overrides:
splitLine in class LpexCommonParser
See Also:
LpexCommonParser.getTextIndent(int)

splitLine

protected void splitLine(boolean undoCheck)
Override the default splitLine behaviour. When text is split, indent it to the same level as the previous line, when applicable. Includes special handling for comments and literals.

Parameters:
undoCheck - set undo checkpoints within the action

join

protected int join()
Override the default join behaviour. When text is joined, remove the leading blanks.

Returns:
1 on a delete line (shift up), 2 on a simple join, 3 on a complex join, -1 otherwise

join

protected int join(boolean undoCheck)
Override the default join behaviour. When text is joined, remove the leading blanks.

Parameters:
undoCheck - set undo checkpoints within the action
Returns:
1 on a delete line (shift up), 2 on a simple join, 3 on a complex join, -1 otherwise

backSpace

protected void backSpace()
Override the default backspace behaviour. If no text is selected, and the position is at the start of a line, perform a join with the previous line instead of a delete. If text is selected, perform a default backspace action, then call split, then join.


delete

protected void delete()
Override the default delete behaviour. If no text is selected, and the position is at the end of a line, perform a join instead of a delete. If text is selected, perform a default delete action, then call split, then join.


parseAll

public void parseAll()
Total parse of the entire document. Done initially, after a document has been loaded in the editor, after an updateProfile command, and after a change to the taskTags parser property.

Specified by:
parseAll in class LpexCommonParser
See Also:
Total and incremental parse

parseElement

public void parseElement(int element)
Incremental parse.

Specified by:
parseElement in class LpexCommonParser
Parameters:
element - an element affected by a committed change in this view
See Also:
LpexView.parsePending(int), LpexView.elementParsed(int), Total and incremental parse

getProfile

public ResourceBundle getProfile()
Returns this parser's profile resource bundle.

Overrides:
getProfile in class LpexCommonParser
See Also:
LpexCommonParser.getProperty(java.lang.String), Parser properties

getLanguage

public String getLanguage()
Returns "PLI", the language supported by this parser (PL/I).

Overrides:
getLanguage in class LpexCommonParser
See Also:
LpexCommonParser.LANGUAGE_PLI

getLanguage

public String getLanguage(LpexDocumentLocation loc)
Returns a string identifying the language segment at the specified location. In mixed-content documents, this may differ from the main language of the document. The method assumes that no parse is pending.

Overrides:
getLanguage in class LpexCommonParser
Parameters:
loc - document location
Returns:
one of:
LpexCommonParser.LANGUAGE_PLI,
LpexCommonParser.LANGUAGE_SQL,
LpexCommonParser.LANGUAGE_CICS,
LpexCommonParser.LANGUAGE_DLI
See Also:
LpexCommonParser.getLanguage(), Mixed content documents

terminateParser

protected void terminateParser()
Cleans up any resources allocated by this parser.

Overrides:
terminateParser in class LpexCommonParser
See Also:
Life cycle

propertySet

protected void propertySet(String key)
Listens to changes to the taskTags parser property in this view.

Overrides:
propertySet in class LpexCommonParser
Parameters:
key - base name of the parser property that was set, for example "autoIndent"
See Also:
LpexCommonParser.setProperty(String,String), LpexCommonParser.getProperty(java.lang.String), Parser properties

getPopupItems

protected String getPopupItems(int popupLocation)
Returns this parser's contribution to the popup. This parser contributes to the Filter view submenu (Procedures, Logic outline, Preprocessor statements, Includes, Extensions, SQL/CICS/DLI, Errors, Tasks).

Overrides:
getPopupItems in class LpexCommonParser
Parameters:
popupLocation - the location on the pop-up 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 pop-up menu, or
null if none
See Also:
LpexCommonParser.defineFilterAction(java.lang.String, java.lang.String)

getPopupItem

protected String getPopupItem(String key)

setStyleAttributes

public void setStyleAttributes()
Defines parser's style attributes. Unscanned text uses the default style character '!'. The following style characters are set: '_' (layout blanks), 'a' (variable/procedure name), 'u' (label), 's' (language symbol), 'g' (extension), '?' (outside margins), 'c' (comment), '$' (comment task tag), 'e' (error), 'k' (keyword), 'b' (built-in function), 'n' (numeric), 'l' (literal), 'q' (preprocessor keyword), 'r' (preprocessor '?').


getCommentStyleCharacters

public String getCommentStyleCharacters()
Returns the style characters used for styling comments ("c$").

Overrides:
getCommentStyleCharacters in class LpexCommonParser

matchToken

protected LpexDocumentLocation matchToken(LpexDocumentLocation loc)
Matches PL/I constructs (e.g., "PROC" - "END").

Overrides:
matchToken in class LpexCommonParser
Parameters:
loc - document location of the token to match
Returns:
matching-token location (with loc adjusted to include the entire original token), or null if not a matchable token, or original loc if no match found for the token

isTokenDelimiter

public boolean isTokenDelimiter(char ch)
Returns whether the specified character is a token delimiter.

Overrides:
isTokenDelimiter in class LpexCommonParser
Parameters:
ch - character queried, for example ')'
See Also:
LpexCommonParser.getToken(com.ibm.lpex.core.LpexDocumentLocation), LpexCommonParser.tokenBegin(com.ibm.lpex.core.LpexDocumentLocation), LpexCommonParser.tokenEnd(com.ibm.lpex.core.LpexDocumentLocation)

getStream

protected final LpexCharStream getStream()
Returns the character stream used by the parser.


nextKeyword

protected String nextKeyword()
Retrieves the next keyword-definition line. This method is being called repeatedly to set up the parser's static keyword tables, until it returns null.

This method may be extended by a subclassing parser to add custom keywords.


getLshToken

public String getLshToken()
Returns the current token for language-sensitive help (LSH). The token returned will serve (in common LSH implementations) as a key into the mapping table to the appropriate help panel. When null is returned, the LSH implementation should display a default language help panel.

In addition to language keywords, this parser generates the following 'tokens' for special situations:

Overrides:
getLshToken in class LpexCommonParser
See Also:
Language-sensitive help

getProperty

public String getProperty(String key)
Extends LpexCommonParser's getProperty() to substitute the arguments for key PROTOKEY_EMPTY. Argument {0} is blanks for the default left margin, {1} is for the procedure name (this substitution is based on the name parameter of the document).

Specified by:
getProperty in interface LpexParser
Overrides:
getProperty in class LpexCommonParser
Parameters:
key - property name, for example, "proto.doc" for this parser's expansion of the keyword "doc" by the proto action, or "view.proto.doc" for this property as defined in the current view's instance of the parser
See Also:
LpexCommonParser.getLanguage(), LpexCommonParser.getProfile(), Parser properties

getLeftMargin

public int getLeftMargin()
Returns the left margin used to parse the document. The default left margin is defined by the parser property leftMargin. The actual left margin used by the parser may be set by PROCESS statements in the document itself.


getRightMargin

public int getRightMargin()
Returns the right margin used to parse the document. The default right margin is defined by the parser property rightMargin. The actual right margin used by the parser may be set by PROCESS statements in the document itself.


getNotCharacters

public String getNotCharacters()
Returns the characters for the logical NOT operator used in the parsing of this document. The default extra NOT characters are defined by the parser property not. The actual characters used by the parser may be set by PROCESS statements in the document itself.


getOrCharacters

public String getOrCharacters()
Returns the characters for the logical OR operator used in the parsing of this document. The default extra OR characters are defined by the parser property or. The actual characters used by the parser may be set by PROCESS statements in the document itself.


getNamesCharacters

public String getNamesCharacters()
Returns the extra characters for names used in the parsing of this document. The default characters for names are defined by the parser property names. The actual characters used by the parser may be set by PROCESS statements in the document itself.


setLineStructure

protected void setLineStructure()
(Re)sets the format line and the editing fields for the left and right margins in effect. Called during total parse, and when the margin settings parsed change during incremental parse.


compileOptionKeywords

public String[] compileOptionKeywords()
Returns a list of the compile-time options defined in this parser.

See Also:
keywords

keywords

public String[] keywords()
Returns a list of the PL/I keywords defined in this parser.

See Also:
compileOptionKeywords()

isKeyword

protected PliParser.Keyword isKeyword(Token token)
Returns whether the given token is a non compile-option PL/I keyword.

Parameters:
token - token to check
Returns:
Keyword, or
null if it is not a PL/I keyword

isKeyword

protected PliParser.Keyword isKeyword(Token token,
                                      int attribute)
Returns whether the given token is a PL/I keyword of a particular attribute.

Parameters:
token - token to check
attribute - its attribute
Returns:
Keyword, or
null if it is not a PL/I keyword of this attribute

hasOwnerSubparser

protected boolean hasOwnerSubparser()
Returns the availability of an owner subparser.

The default implementation of this method returns false.


isOwnerElement

protected boolean isOwnerElement(int element)
Returns whether the specified text element should be parsed by the custom lexer (LEXER_OWNER).

The default implementation of this method returns false.


getLexer

protected LpexSubparser getLexer(int lexer,
                                 LpexCharStream lexerStream)
Returns the specified subparser. This method constructs and returns a lexer object for parsing embedded EXEC SQL, EXEC CICS, EXEC DLI, or custom statements.

The default implementation of this method returns null for LEXER_DLI and LEXER_OWNER requests.

Parameters:
lexer - lexer requested, one of LEXER_SQL, LEXER_CICS, LEXER_DLI, LEXER_OWNER
lexerStream - input character stream for the lexer

LPEX
4.4.0

Copyright � 2016 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.