com.ibm.lpex.cpp
Class CppParser
java.lang.Object
com.ibm.lpex.core.LpexCommonParser
com.ibm.lpex.cpp.CppParser
- All Implemented Interfaces:
- LpexConstants, LpexParser
- Direct Known Subclasses:
- CppCicsParser, CppParserAIX, CppParserOS2, CppParserWIN, CppSqlParser
- public class CppParser
- extends LpexCommonParser
Document parser for C/C++.
This class is extended by various C/C++ document parsers for specific
systems/platforms and embedded SQL/CICS support.
Actions and assigned keys added by this document parser:
- comment (Ctrl+/) - to comment the visible selected elements
- errors - for a selective view of the errors in the document
- functions (Ctrl+G) - for a selective view of the functions
in the document
- outline - for a logical-outline view of the document
- uncomment (Ctrl+\) - to uncomment the visible selected elements.
Keys already defined (e.g., by the active base profile) to an action
different from nullAction are not redefined in here.
Action modified by this document parser:
- contextHome - to skip comment-defining characters when determining
the start of the text.
Template expansion (proto action, Ctrl+R) for the following keywords
is provided in this parser's profile:
- case
- do
- doc
- for
- if
- main
- switch
- try
- while.
- See Also:
- CppParserOS2,
CppParserWIN,
CppParserAIX,
CppSqlParser,
CppSqlParserOS2,
CppSqlParserWIN,
CppSqlParserAIX
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
|
Methods inherited from class com.ibm.lpex.core.LpexCommonParser |
addMessage, addMessage, addMessage, blockMarkWord, cursorIndent, expandProtoKeyword, getInstallStyleAttributes, getPopupParserItems, getPopupViewItems, getProperty, getStyleName, getStyles, getTextIndent, getToken, getTokenLocation, indentText, indentText, indentText, lineComment, lpexView, matchToken, newLine, openLine, parse, removeMessages, removeMessages, resetParser, setProperty, setStyle, splitLine, styleString, terminateParser, tokenBegin, tokenEnd, totalParse
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
|
CppParser
public CppParser(LpexView lpexView)
- Constructor for the parser.
Adds all of the parser specifics to the LPEX document view.
Initializes the view for the parser: sets up all the style
attributes, classes, etc. for the language-sensitive edit features
supported.
- Parameters:
- lpexView - the document view associated with this parser
parseAll
public void parseAll()
- Total parse of the entire document.
Done initially, after a document has been loaded in the editor, and
after an updateProfile command.
- 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 - the (first) 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
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 "CPP", the language supported by this parser (C/C++).
- Overrides:
- getLanguage in class LpexCommonParser
- See Also:
- LpexCommonParser.LANGUAGE_CCPP
getLanguage
public String getLanguage(LpexDocumentLocation loc)
- Retrieve 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 for this location's element.
- Overrides:
- getLanguage in class LpexCommonParser
- Returns:
- one of: LpexCommonParser.LANGUAGE_CCPP,
LpexCommonParser.LANGUAGE_CICS,
LpexCommonParser.LANGUAGE_SQL
- See Also:
- LpexCommonParser.getLanguage()
getPopupItems
protected String getPopupItems(int popupLocation)
- Retrieve parser's contribution to the popup.
This parser contributes to the "Filter view" submenu (Functions,
Logic outline, Errors) and to the "Source" submenu (Comment, Uncomment).
- 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()
- Define parser's style attributes.
The following style characters are set:
'_' (layout blanks),
'k' (keyword),
'x' (extension keyword),
'i' (identifier),
'n' (integer/character literal),
'l' (floating-point literal),
'q' (string literal),
'o' (operator),
'p' (punctuation),
't' (continuation character),
'c' (comment),
'f' (C library function),
'b' (brace),
'h' (CPP directive),
'e' (error).
getCommentStyleCharacters
public String getCommentStyleCharacters()
- Return the style character used for styling comments ("c"). This is used
by compare sessions when the compare.ignoreComments option
is in effect.
- Overrides:
- getCommentStyleCharacters in class LpexCommonParser
isDebuggable
public boolean isDebuggable(int line)
- Query whether the specified document line is debuggable. A line is
debuggable when it contains executable code that a debugger may stop on.
This method is used to identify lines on which a breakpoint may be set.
- Overrides:
- isDebuggable in class LpexCommonParser
- Parameters:
- line - a line inside the document section that is currently loaded
in the editor
isTokenDelimiter
public boolean isTokenDelimiter(char ch)
- Returns true if the specified character is a token delimiter.
- Overrides:
- isTokenDelimiter in class LpexCommonParser
- See Also:
- LpexCommonParser.getToken(com.ibm.lpex.core.LpexDocumentLocation)
addErrorMessage
protected void addErrorMessage(int element,
String message)
- Display an embedded error message for an element.
- Parameters:
- element - the element in error
- message - error message key in LPEX's Resources.properties
isExtensionKeyword
public boolean isExtensionKeyword(com.ibm.lpex.cc.Token token)
- Returns true if the token passed is an extension keyword.
CppParser has no particular system/platform flavour, so it will
always return false.
A document parser extending class CppParser must override this method
to check for extension keywords for the system / platform it applies to.
Other extensions (such as for a particular project / compiler) may also be
supported in this manner.
isCLibraryFunction
public boolean isCLibraryFunction(com.ibm.lpex.cc.Token token)
- Returns true if the token passed is a C library function.
A document parser extending CppParser must override this method to check
for C library & extension C library functions available on the system /
platform it applies to.
setLexer
protected boolean setLexer(int newLexer)
- Set/switch the active lexer.
- Parameters:
- newLexer - the new lexer, one of: LEXER_CPP, LEXER_SQL, or LEXER_CICS
- Returns:
- true = new lexer has been set as the active lexer,
and initialized in its DEFAULT lexical state
getSqlLexer
public SqlLexer getSqlLexer(LpexCharStream sqlLexerStream)
- Retrieve the SqlLexer.
The document parser extending CppParser to support embedded SQL statements
must override this method to construct and return an SqlLexer object.
The implementation of this method provided by the CppParser class does
nothing, except return null.
- Parameters:
- sqlLexerStream - input character stream for the SQL lexer
getCicsLexer
public CicsLexer getCicsLexer(LpexCharStream cicsLexerStream)
- Retrieve the CicsLexer.
The document parser extending CppParser to support embedded CICS statements
must override this method to construct and return a CicsLexer object.
The implementation of this method provided by the CppParser class does
nothing, except return null.
- Parameters:
- cicsLexerStream - input character stream for the CICS lexer
getLshToken
public String getLshToken()
- Get 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:
- lexical errors:
badoctal_error
- embedded CICS/SQL:
sql,
cics
- comments:
comment_help
- continuation character:
cont_char_help
- identifiers:
identifier_help
- literals:
constant_help,
fpoint_literal_help,
char_literal_help,
string_literal_help
- braces:
braces_help
- punctuators:
period_help,
comma_help,
colon_help,
brackets_help,
parens_help,
semicolon_help
- operators:
equal_help,
assignment_op_help,
conditional_help,
bit_or_help,
bit_xor_help,
comp_op_help,
modulo_help,
divide_help,
multiply_help,
plus_help,
minus_help,
complement_help,
negation_help,
bit_and_help,
pound_help,
shifts_help,
increment_help,
decrement_help,
pointer_help,
logic_and_help,
logic_or_help,
equality_help,
notequal_help,
poundpound_help,
scope_help
- preprocessor directives:
pragma_help,
include_help,
define_help,
undef_help,
error_help,
elif_help,
else_help,
endif_help,
if_help,
ifdef_help,
ifndef_help,
line_help,
directive_help.
- Overrides:
- getLshToken in class LpexCommonParser
- See Also:
- Language-sensitive help