@@ -49,9 +49,9 @@ class Lexer {
4949 * @public
5050 * @readonly
5151 * @instance
52- * @member {Optional< Token> } head
52+ * @member {Token} head
5353 */
54- public readonly head ?: Optional < Token >
54+ public readonly head : Token
5555
5656 /**
5757 * Lexer options.
@@ -77,18 +77,6 @@ class Lexer {
7777 */
7878 protected readonly reader : Reader
7979
80- /**
81- * Tail token.
82- *
83- * @see {@linkcode Token }
84- *
85- * @public
86- * @readonly
87- * @instance
88- * @member {Optional<Token>} tail
89- */
90- public readonly tail ?: Token | undefined
91-
9280 /**
9381 * Token sequence.
9482 *
@@ -117,9 +105,7 @@ class Lexer {
117105 this . options = Object . freeze ( options ??= { } )
118106 this . reader = new Reader ( value , this . options . from )
119107 this . tokens = [ ]
120-
121108 this . head = this . tokenize ( )
122- this . tail = this . tokens . at ( - 1 )
123109 }
124110
125111 /**
@@ -333,9 +319,9 @@ class Lexer {
333319 * @protected
334320 * @instance
335321 *
336- * @return {Token | undefined } Head token
322+ * @return {Token } Head token
337323 */
338- protected tokenize ( ) : Token | undefined {
324+ protected tokenize ( ) : Token {
339325 while ( ! this . reader . eof ) {
340326 ok ( this . reader . char , 'expected character' )
341327
@@ -370,7 +356,10 @@ class Lexer {
370356 }
371357 }
372358
373- return this . tokens [ 0 ]
359+ this . enter ( kinds . eof , '' )
360+ this . exit ( kinds . eof )
361+
362+ return this . tokens [ 0 ] !
374363 }
375364
376365 /**
0 commit comments