| | package com.keenwrite.quotes; |
| | |
| | -import java.util.ArrayDeque; |
| | -import java.util.Deque; |
| | +import java.util.ArrayList; |
| | +import java.util.List; |
| | import java.util.function.Consumer; |
| | |
| | import static com.keenwrite.quotes.Contractions.beginsUnambiguously; |
| | import static com.keenwrite.quotes.Lexeme.EOT; |
| | import static com.keenwrite.quotes.LexemeType.*; |
| | import static com.keenwrite.quotes.TokenType.*; |
| | +import static java.util.Comparator.comparingInt; |
| | |
| | /** |
 |
| | private final Lexer mLexer; |
| | |
| | - private final Deque<Lexeme> mQuotations = new ArrayDeque<>(); |
| | + private final List<Lexeme[]> mQuotationMarks = new ArrayList<>(); |
| | private final CircularFifoQueue<Lexeme> mLexemes = |
| | new CircularFifoQueue<>( 3 ); |
 |
| | for( int i = 0; i < mLexemes.size(); i++ ) { |
| | parse( mLexemes.get( i ), consumer ); |
| | + } |
| | + |
| | + mQuotationMarks.sort( comparingInt( lexemes -> lexemes[ 0 ].began() ) ); |
| | + |
| | + for( final var unparsed : mQuotationMarks ) { |
| | + System.out.println( "unparsed: " + unparsed[ 0 ] + " " + unparsed[ 1 ] + " " + unparsed[ 2 ] ); |
| | } |
| | |
 |
| | } |
| | else if( lex1.isType( QUOTE_SINGLE ) && lex2.isType( WORD ) && |
| | - // E.g., 'contraction |
| | + // E.g., 'twas |
| | beginsUnambiguously( lex2.toString( mText ) ) ) { |
| | consumer.accept( new Token( QUOTE_APOSTROPHE, lex1 ) ); |
 |
| | consumer.accept( new Token( QUOTE_STRAIGHT_DOUBLE, lex1 ) ); |
| | } |
| | - else if( lex1.anyType( QUOTE_SINGLE, QUOTE_DOUBLE ) ) { |
| | - mQuotations.push( lex1 ); |
| | - System.out.println( "FOUND QUOTE: " + lex1 + " " + lex1.toString( mText ) ); |
| | + else if( lex2.anyType( QUOTE_SINGLE, QUOTE_DOUBLE ) ) { |
| | + mQuotationMarks.add( new Lexeme[]{lex1, lex2, lex3} ); |
| | } |
| | } |