package Breccia.parser.plain; import Breccia.parser.AdjunctSlow; import Breccia.parser.Fractum; import static Java.Classes.nameWithoutPackageLeader; /** @param The type of cursor. */ abstract class Fractum_ extends Granum_ implements Fractum { Fractum_( final C cursor ) { super( cursor ); this.cursor = cursor; } /** Sets this fractum as the present parse state. */ void commit() { cursor.fractum( this ); } protected final C cursor; /** The corresponding end state of this fractum. */ protected End_ end; // ━━━ F r a c t u m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ public final @Override int lineCount() { return cursor.fractumLineEnds.length; } public final @Override int xuncLineEnd( final int i ) { if( i >= lineCount() ) throw new IndexOutOfBoundsException( i ); return cursor.xunc + cursor.fractumLineEnds.array[i]; } // ━━━ G r a n u m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ public final @Override @AdjunctSlow int lineNumber() { return cursor.fractumLineNumber(); } // ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ /** The end of a fractum. */ abstract class End_ implements Fractum.End { void commit() { cursor.fractumEnd( this ); } public @Override String toString() { return nameWithoutPackageLeader( getClass() ); }}} // Copyright © 2021-2022 Michael Allan. Licence MIT.