Class UtilParseQuote
java.lang.Object
org.libxmq.imp.UtilQuote
org.libxmq.imp.UtilParseQuote
Utility for parsing xmq quotes.
-
Field Summary
Fields inherited from class UtilQuote
all_leading_, buffer_, buffer_start_, buffer_stop_, debug_, first_ending_nl_, last_indent_, last_leading_nl_, lines_, max_num_consecutive_double_quotes_, max_num_consecutive_single_quotes_, min_indent_, needs_compound_, num_ending_nl_, num_leading_nl_, num_nl_, start_, stop_Modifier and TypeFieldDescriptionprotected booleanSet to true if the quote only consists of newlines and spaces.protected StringWe analyze part of a larger buffer, typically the whole xmq source file.protected intThe buffer_start_ points to where in the larger buffer_ we find the quote to be parsed.protected intThe buffer_stop_ points to just after the quote to be parsed.protected static final booleanDebug flag, currently disabled.protected intStores the index of the first ending newline characters after which lines do not contain non-space characters.protected intWhile looking for the first ending newline, remember the last indent.protected intStores the index of the last leading newline character after which the line contains non-space characters.protected ArrayList<org.libxmq.imp.Line> Stores start,stop,nl for each line found inside a quote.protected intMaximum number of consecutive double quotes found.protected intMaximum number of consecutive single quotes found.protected intThe minimum indentation found.protected booleanTrue if a compound quote form is needed.protected intStores the number of ending newline characters found after the last line with non-space characters.protected intStores the number of leading newline characters found before the first line with non-space characters.protected intTotal number of newlines.protected intStart stores the index either buffer_start_, if no leading newlines are found or start stores the last_leading_nl+1, ie the first character of the first line with non-space characters.protected intStop stores the index either buffer_stop_, if no ending newlines are found or stop stores the first_ending_nl, ie after the end of the last line with non-space characters. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUtilParseQuote(String b, int start, int stop) Creates a quote parser. -
Method Summary
Modifier and TypeMethodDescriptionvoidAnalyzes the quote for parsing.protected intcountSame(int start, int stop) Look at the char at index start and count how many identical chars there are forward.findCommentStartStop(String b, int start, int stop) Expects an xmq comment "// " or "/∗ ... ∗/" or "////∗ ∗////" or a comment continuation "∗protected voidScans the buffer for trailing newlines and spaces.protected voidScans q_ for leading newline ('\n') and space (' ') characters.findQuoteStartStop(String b, int start, int stop) Expects an xmq quote and removes the surrounding single or double quote chars.protected StringParses the quote into its content.static StringTrims a quote according to xmq quoting rules.
-
Constructor Details
-
UtilParseQuote
Creates a quote parser.- Parameters:
b- The buffer to parse.start- The start index of the quote.stop- The stop index of the quote.
-
-
Method Details
-
findQuoteStartStop
Expects an xmq quote and removes the surrounding single or double quote chars. For example: '' -> (1,1)- Parameters:
b- The buffer to search.start- The start index of the quote.stop- The stop index of the quote.- Returns:
- The (start,stop) pair of the inner content.
-
findCommentStartStop
Expects an xmq comment "// " or "/∗ ... ∗/" or "////∗ ∗////" or a comment continuation "∗ .... ∗/"- Parameters:
b- The buffer to search.start- The start index of the comment.stop- The stop index of the comment.- Returns:
- The (start,stop) pair of the inner content.
-
trimQuote
-
countSame
protected int countSame(int start, int stop) Look at the char at index start and count how many identical chars there are forward. Used to count identical quotes in a sequence or count number of spaces used for indentation. -
findLeadingNewlines
protected void findLeadingNewlines()Scans q_ for leading newline ('\n') and space (' ') characters.The method identifies sequences of newlines and spaces at the start of the string and determines the index of the last newline that precedes a line with non-space content.
Example
q_ = " \n \n Hello World"; findLeadingNewlines(); // num_leading_nl_ = 2 // last_leading_nl_ = 4- Overrides:
findLeadingNewlinesin classUtilQuote
-
findEndingNewlines
protected void findEndingNewlines()Scans the buffer for trailing newlines and spaces.- Overrides:
findEndingNewlinesin classUtilQuote
-
analyzeForParse
public void analyzeForParse()Analyzes the quote for parsing. -
parseQuote
-