Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenquotes.git

Formatting, code reorg

AuthorDave Jarvis <email>
Date2022-08-13 16:43:07 GMT-0700
Commitcd880ed905f3782484617c873ffd41e547d03b67
Parent3cca8ab
src/main/java/com/whitemagicsoftware/keenquotes/Lexeme.java
/**
- * Extracts a sequence of characters from the given text at the offsets
- * captured by this lexeme.
- *
- * @param text The text that was parsed using this class.
- * @return The character string captured by the lexeme.
- */
- public String toString( final String text ) {
- assert text != null;
- return text.substring( mBegan, mEnded );
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + '[' +
- "mType=" + mType +
- ", mBegan=" + mBegan +
- ", mEnded=" + mEnded +
- ']';
- }
-
- /**
* Answers whether the given {@link LexemeType} is the same as this
* instance's internal {@link LexemeType}.
assert that != null;
return this.mBegan - that.mBegan;
+ }
+
+ /**
+ * Extracts a sequence of characters from the given text at the offsets
+ * captured by this lexeme.
+ *
+ * @param text The text that was parsed using this class.
+ * @return The character string captured by the lexeme.
+ */
+ public String toString( final String text ) {
+ assert text != null;
+ return text.substring( mBegan, mEnded );
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + '[' +
+ "mType=" + mType +
+ ", mBegan=" + mBegan +
+ ", mEnded=" + mEnded +
+ ']';
}
}
src/main/java/com/whitemagicsoftware/keenquotes/Lexer.java
* then end of text.
*
- * @param text The sequence of characters to tokenize.
+ * @param text The sequence of characters to tokenize.
+ * @param emitter Recipient of all tokenized character sequences.
+ * @param filter Tokenization preprocessor, usually empty, but can be used
+ * to skip certain character sequences (such as XML tags).
*/
- public static void lex(
- final String text,
- final Consumer<Lexeme> emitter ) {
- lex( text, emitter, filter -> {} );
- }
-
public static void lex(
final String text,
token =
i.skip( next -> next == '.' || next == ' ' && i.peek() == '.' ) == 0
- ? PERIOD
- : ELLIPSIS;
+ ? PERIOD
+ : ELLIPSIS;
}
else if( curr == '"' ) {
Delta27 lines added, 30 lines removed, 3-line decrease