|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pz.platypus.PlatypusParser
public class PlatypusParser
The primary parser for Platypus files. It parses input into core elements: - text - commands and macros - comments, both line and block format
Field Summary | |
---|---|
private java.lang.String |
blockCommentClosingSymbol
the symbol we need to match for the close of a block of |
private CommandTable |
ctable
the ComandTable that holds all the commands that Platypus supports |
private GDD |
gdd
|
private boolean |
inCode
are we in code? If so, this changes how we isLineComment text. |
Constructor Summary | |
---|---|
PlatypusParser(GDD Gdd)
|
Method Summary | |
---|---|
void |
addToken(TokenList tokens,
TokenType tokType,
java.lang.String content,
Source source)
Adds a parsed token to the ArrayList of tokens |
private boolean |
blockClosesOnSameLine(ParseContext context,
java.lang.String blockCommentClosingSymbol)
|
static boolean |
doesPlatypusParse(PropertyFile configFile,
java.lang.String pluginPrefix)
Do we do the parsing, or will the output plugin do the parsing? Check the config file for what the plug-in specifies. |
(package private) void |
emitEolToken(TokenList newTokens,
Source source)
Emits the so-called "soft" EOL command used when at end of line. |
java.lang.String |
extractCommandRoot(ParseContext context)
Extracts the root of a command. |
private int |
handleClosingBlockComment(TokenList newTokens,
ParseContext context,
int closeCommentStart)
Write the closed block comment to the token list and return the amount by which the isLineComment point needs to be moved up to get past the block comment. |
(package private) void |
invalidCommandError(ParseContext context,
TokenList tokens,
java.lang.String commandRoot)
Write an error message to console saying that the command-like token is not actually a Platypus command, and then write the token out to the output as a text token. |
boolean |
isInCode()
|
int |
noParse(LineList lines,
TokenList tokens)
Some output plugins want to parse the input text themselves. |
private int |
outputMacroAsToken(ParseContext context,
TokenList tokens,
MacroParser mp)
Outputs the macro to the TokenList without expanding it. |
int |
parse(LineList lines,
TokenList tokens,
PropertyFile configFile,
java.lang.String pluginPrefix)
Converts input lines into an ArrayList of parsed tokens. |
int |
parseLine(TokenList newTokens,
InputLine line)
Parse a line of the input file |
int |
parseSegment(ParseContext context,
TokenList tokens)
The primary line-parsing routine. |
(package private) boolean |
passThroughEscapeChar()
Check the config file to see whether we pass through the escape char to the output token stream. |
int |
processBlockComment(ParseContext context,
TokenList tokens)
Processes block comments. |
int |
processCommand(ParseContext context,
TokenList tokens)
Just grabs the command and writes it to the token list |
int |
processMacro(ParseContext context,
TokenList tokens)
If the config file for this output format says that Platypus expands macros, this routine looks up the macro, expands it, and puts the expanded form in gdd.expandedMacro. |
void |
setInCode(boolean inCodeYesOrNo)
|
int |
writeOutText(int start,
int end,
char[] text,
TokenList tokensOut,
Source source)
Write out a set of text characters to the token list as a text token |
private void |
writeOutText(ParseContext context,
int endPoint,
TokenList tokens)
Write out text Token to the token list |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean inCode
private java.lang.String blockCommentClosingSymbol
private CommandTable ctable
private GDD gdd
Constructor Detail |
---|
public PlatypusParser(GDD Gdd)
Method Detail |
---|
public int parse(LineList lines, TokenList tokens, PropertyFile configFile, java.lang.String pluginPrefix)
lines
- the input linestokens
- the resulting tokensconfigFile
- the configuration file might have info on how to handle some featurespluginPrefix
- the prefix to look up output items with in the config file
public int parseLine(TokenList newTokens, InputLine line)
line
- line to be parsednewTokens
- the TokenList to which we're adding tokens
void emitEolToken(TokenList newTokens, Source source)
newTokens
- token list to add the token tosource
- file# and line# of tokenprivate int handleClosingBlockComment(TokenList newTokens, ParseContext context, int closeCommentStart)
newTokens
- what we write the tokens tocontext
- the parsing context infocloseCommentStart
- where the beginning of the close to the block comment is
public int parseSegment(ParseContext context, TokenList tokens)
context
- the source context datatokens
- the sequence of tokens to which we'll add the parsed segment.
boolean passThroughEscapeChar()
private void writeOutText(ParseContext context, int endPoint, TokenList tokens)
context
- where the text string isendPoint
- the end of the text (starts at context.startPoint)tokens
- the token list to write the token to.public int processBlockComment(ParseContext context, TokenList tokens)
tokens
- the token list to add the block-comment token tocontext
- the parser context/location info.
private boolean blockClosesOnSameLine(ParseContext context, java.lang.String blockCommentClosingSymbol)
public int processCommand(ParseContext context, TokenList tokens)
context
- parse context: sourcefile# & line#, parsePoint, line as string, line as char[]tokens
- token list to which we will add the tokens derived from the command
void invalidCommandError(ParseContext context, TokenList tokens, java.lang.String commandRoot)
context
- the parser contexttokens
- list of tokens to which this token will be addedcommandRoot
- the root of the command, were it a real command.public java.lang.String extractCommandRoot(ParseContext context) throws java.lang.IndexOutOfBoundsException
context
- the parsing location info.
java.lang.IndexOutOfBoundsException
- for unclosed commandpublic int processMacro(ParseContext context, TokenList tokens)
tokens
- list of tokens we're building up in parser. (Used only if macros not processed)context
- the parsing context info
private int outputMacroAsToken(ParseContext context, TokenList tokens, MacroParser mp)
context
- the parsing context datatokens
- the TokenList to which the token is writtenmp
- the macro parser class
public int writeOutText(int start, int end, char[] text, TokenList tokensOut, Source source)
start
- subscript of first char in textend
- subscript of last char in texttext
- array of chars containing the line from which the text is extractedtokensOut
- the list of tokens to which the text token will be addedsource
- the file# and line#
public static boolean doesPlatypusParse(PropertyFile configFile, java.lang.String pluginPrefix)
configFile
- the configuration filepluginPrefix
- the prefix for this output plugin
public void addToken(TokenList tokens, TokenType tokType, java.lang.String content, Source source)
tokens
- the ArrayList of tokens to add totokType
- the type of token we're adding (an enum in Platypus.TokenType)content
- the user entered text that's been parsed into a tokensource
- the file# and line# in the input file where the token was foundpublic int noParse(LineList lines, TokenList tokens)
lines
- ArrayList of input linestokens
- ArrayList of output tokens (consisting of the unparsed lines)
public boolean isInCode()
public void setInCode(boolean inCodeYesOrNo)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |