Dave Jarvis' Repositories

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

Fix test for dimensions, add vulgar fractions

AuthorDave Jarvis <email>
Date2022-05-01 23:20:06 GMT-0700
Commit18f95f293051ae776e3fad1adab7ac0eecce8399
Parentf7f2d20
src/main/java/com/whitemagicsoftware/keenquotes/Lexer.java
import static com.whitemagicsoftware.keenquotes.Lexeme.createLexeme;
import static com.whitemagicsoftware.keenquotes.LexemeType.*;
-import static java.lang.Character.isDigit;
import static java.lang.Character.isWhitespace;
import static java.text.CharacterIterator.DONE;
isWord = true;
- if( !isLetter( peek( i ) ) ) {
+ final var next = peek(i);
+
+ if( !isLetter( next ) && !isDigit( next ) ) {
lexeme = createLexeme( WORD, began, i.getIndex() );
}
private static boolean isLetter( final char curr ) {
return Character.isLetter( curr ) || curr == '_' || curr == '*';
+ }
+
+ private static boolean isDigit( final char curr ) {
+ return Character.isDigit( curr ) ||
+ "¼½¾⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞".indexOf( curr ) > -1;
}
/**
* Answers whether the given character can be considered part of a number
* or not. This does not include digits, which are checked independently
- * from this method.
+ * of this method.
*
- * @param curr The character to check as being related to numbers.
+ * @param curr The character to check as being related to a number.
* @return {@code true} if the given character can be considered part of
* a number (e.g., -2,000.2^2 is considered a single number).
*/
private static boolean isNumeric( final char curr ) {
return
- curr == '.' || curr == ',' || curr == '-' || curr == '+' || curr == '^';
+ curr == '.' || curr == ',' || curr == '-' || curr == '+' ||
+ curr == '^' || curr == '⅟' || curr == '⁄';
}
src/test/resources/com/whitemagicsoftware/keenquotes/smartypants.txt
12&Prime; record, 5&prime;10&Prime; height
-Use 11.5"x14.25" virtual paper!
-Use 11.5&Prime;x14.25&Prime; virtual paper!
+Use 11.5"×14.25" virtual paper!
+Use 11.5&Prime;×14.25&Prime; virtual paper!
Angular measure 3° 5' 30" means 3 degs, 5 arcmins, & 30 arcsecs.
Angular measure 3° 5&prime; 30&Prime; means 3 degs, 5 arcmins, & 30 arcsecs.
+
+Play 12½" records.
+Play 12½&Prime; records.
# ########################################################################
"Will'll invite?" Mrs. Thorne asked;\n"because he's coming--he's at the gate."
&ldquo;Will&apos;ll invite?&rdquo; Mrs. Thorne asked;\n&ldquo;because he&apos;s coming--he&apos;s at the gate.&rdquo;
+
+Model "T2000"
+Model &ldquo;T2000&rdquo;
# ########################################################################
Delta20 lines added, 7 lines removed, 13-line increase