| Author | Dave Jarvis <email> |
|---|---|
| Date | 2022-10-05 23:26:49 GMT-0700 |
| Commit | 8509d5e9f013307d5256ac85012607a31f2c2a31 |
| Parent | 6396260 |
| */ | ||
| public enum LexemeGlyph { | ||
| - LEX_NONE( (char) 0 ), | ||
| + /** | ||
| + * Any other character that's not a quotation mark. | ||
| + */ | ||
| + LEX_OTHER( (char) 0 ), | ||
| LEX_SINGLE_QUOTE( '\'' ), | ||
| LexemeGlyph( final char glyph ) { | ||
| mGlyph = glyph; | ||
| - } | ||
| - | ||
| - public char glyph() { | ||
| - return mGlyph; | ||
| } | ||
| - public boolean equals( final char ch ) { | ||
| - return glyph() == ch; | ||
| + /** | ||
| + * Answers whether the given character matches the internal glyph. | ||
| + * | ||
| + * @param glyph The character to compare against the internal character. | ||
| + * @return {@code true} iff the characters are equal. | ||
| + */ | ||
| + public boolean equals( final char glyph ) { | ||
| + return mGlyph == glyph; | ||
| } | ||
| } | ||
| private LexemeGlyph mGlyph; | ||
| + /** | ||
| + * Constructs an instance of {@link LexemeType} using | ||
| + * {@link LexemeGlyph#LEX_OTHER} to indicate that this type of lexeme isn't | ||
| + * a quotation mark glyph. | ||
| + */ | ||
| public LexemeType() { | ||
| - this( LEX_NONE ); | ||
| + this( LEX_OTHER ); | ||
| } | ||
| + /** | ||
| + * Constructs an instance of {@link LexemeType} using a particular glyph. | ||
| + * | ||
| + * @param glyph Typically represents an internationalized quotation mark | ||
| + * character. | ||
| + */ | ||
| public LexemeType( final LexemeGlyph glyph ) { | ||
| setGlyph( glyph ); | ||
| } | ||
| + /** | ||
| + * Changes the type of glyph associated with this type of lexeme. This | ||
| + * is useful for passing along different glyphs represented by the same | ||
| + * lexeme (such as different opening quotation marks). | ||
| + * | ||
| + * @param glyph The new {@link LexemeGlyph} to associate, often an | ||
| + * internationalized quotation mark. | ||
| + * @return {@code this} to allow chaining. | ||
| + */ | ||
| public LexemeType with( final LexemeGlyph glyph ) { | ||
| setGlyph( glyph ); | ||
| return this; | ||
| } | ||
| + /** | ||
| + * Provides the glyph used to identify international quotation marks. | ||
| + * | ||
| + * @return The glyph set either at construction time or after calling | ||
| + * {@link #with(LexemeGlyph)}. | ||
| + */ | ||
| public LexemeGlyph glyph() { | ||
| return mGlyph; | ||
| } | ||
| private void setGlyph( final LexemeGlyph glyph ) { | ||
| mGlyph = glyph; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Provides useful debugging information. | ||
| + * | ||
| + * @return The class name and encodable glyph. | ||
| + */ | ||
| + @Override | ||
| + public String toString() { | ||
| + return getClass().getSimpleName() + | ||
| + '[' + glyph() + ']'; | ||
| } | ||
| } |
| assert !replacements.isEmpty(); | ||
| assert i18n != null; | ||
| - assert !i18n.isEmpty(); | ||
| assert parserType != null; | ||
| } | ||
| } | ||
| + // <'"Trouble> | ||
| + else if( match( QUOTE_SINGLE, QUOTE_DOUBLE, WORD, ANY ) ) { | ||
| + emit( QUOTE_OPENING_DOUBLE, lex2 ); | ||
| + } | ||
| else if( match( ANY, QUOTE_DOUBLE, ANY, ANY ) ) { | ||
| emit( QUOTE_AMBIGUOUS_DOUBLE, lex2 ); |
| } | ||
| - @Test | ||
| @Disabled | ||
| void test_Resolve_InvalidGrammar_AmbiguousRemain() throws IOException { |
| @Test | ||
| void test_Emit_MultipleInputs_QuotesEmitted() throws IOException { | ||
| - final var couplets = readPairs( | ||
| - "unambiguous-1-pass.txt" ); | ||
| + final var couplets = readPairs( "unambiguous-1-pass.txt" ); | ||
| couplets.forEach( couplet -> { |
| -# """wtf""" | ||
| -# “““wtf””” | ||
| +"""insane""" | ||
| +“”“insane”“” | ||
| -# '''wtf''' | ||
| -# ‘‘‘wtf’’’ | ||
| +'''wtf''' | ||
| +‘‘‘wtf’’’ | ||
| Delta | 59 lines added, 16 lines removed, 43-line increase |
|---|