Keyboard shortcuts

Press โ† or โ†’ to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Lexer Errors (LTX::LEXER::E001-E011)

The lexer transforms source text into a token stream during the initial compilation phase. This section enumerates all lexer-related errors, their causes, and recommended resolutions.

Error Reference Table

CodeVariantDiagnostic MessageRemediation
LTX::LEXER::E001UnexpectedTokenUnexpected token encounteredValidate input for invalid characters, malformed commands, or unsupported syntax at the reported position.
LTX::LEXER::E002UnexpectedEOFUnexpected end of fileConfirm all environments, brace pairs, and command arguments are properly terminated.
LTX::LEXER::E003UnmatchedBraceUnmatched brace detectedEnsure every opening { has a corresponding closing } and braces are correctly nested.
LTX::LEXER::E004InvalidMathDelimiterInvalid math delimiter detectedValidate usage of math delimiters: $, $$, \(, \), \[, and \].
LTX::LEXER::E005UnterminatedArgumentCommand argument not terminatedAppend missing closing brace } to the command argument.
LTX::LEXER::E006InvalidEscapeSequenceInvalid escape sequenceVerify the command name following the backslash \ is valid.
LTX::LEXER::E007InvalidUnicodeInvalid UTF-8 sequence detectedRe-save the source file with UTF-8 encoding.
LTX::LEXER::E008IllegalParameterCharIllegal parameter character usageEnsure # is used only in macro definitions and follows correct syntax.
LTX::LEXER::E009UnterminatedVerbatimVerbatim environment not terminatedClose the verbatim environment with appropriate termination markers.
LTX::LEXER::E010InvalidCharacterInvalid character encounteredRemove or replace unsupported character at the reported position.
LTX::LEXER::E011MismatchedEnvironmentEnvironment close tag mismatchClose each \begin{env} with an \end{env} of the same name.

Error Categories

Syntax Errors (LTX::LEXER::E001-E006)

These errors occur when the input violates lexical grammar rules.

LTX::LEXER::E001 - UnexpectedToken
The lexer encountered a sequence that does not form a valid token in the current state. Check for:

  • Special characters in invalid contexts
  • Malformed commands or arguments
  • Syntax that does not conform to the language specification

LTX::LEXER::E002 - UnexpectedEOF
The source input terminated prematurely. Verify that:

  • All environment blocks are closed
  • Every opening brace has a matching closure
  • Command argument lists are complete

LTX::LEXER::E003 - UnmatchedBrace
Brace matching failed during tokenization. Inspect:

  • Brace pair count (each { requires a })
  • Brace nesting order
  • Arguments enclosed within braces

LTX::LEXER::E004 - InvalidMathDelimiter
Math mode delimiters are incorrectly specified. Valid delimiters:

  • Inline: $...$ or \(...\)
  • Display: $$...$$ or \[...\]

LTX::LEXER::E005 - UnterminatedArgument
A command argument lacks its closing brace. Each { that starts an argument must have a matching }.

LTX::LEXER::E006 - InvalidEscapeSequence
The sequence following a backslash does not form a valid command. Ensure the command name consists of valid characters and exists in the context.

Encoding and Character Errors (LTX::LEXER::E007-E010)

These errors relate to character encoding and invalid character handling.

LTX::LEXER::E007 - InvalidUnicode
The source file contains bytes that do not form valid UTF-8 sequences. Re-encode the file using UTF-8.

LTX::LEXER::E008 - IllegalParameterChar
The # character is used in an invalid context. Proper usage:

  • Macro parameter references: #1, #2, etc.
  • Macro definitions only

LTX::LEXER::E009 - UnterminatedVerbatim
A verbatim environment was opened but not closed. Ensure the verbatim block terminates correctly.

LTX::LEXER::E010 - InvalidCharacter
The lexer encountered a character not permitted in the current context. Remove or replace the offending character.

Environment Errors (LTX::LEXER::E011)

LTX::LEXER::E011 - MismatchedEnvironment
An \end{...} names a different environment than the one opened by the matching \begin{...}, or an \end appears with no corresponding \begin. Every environment must be closed with the same name it was opened with.

Diagnostic Example

๐Ÿ” Found 1 issue(s):

LTX::LEXER::E001

  ร— unexpected token `@`
   โ•ญโ”€[main.tex:3:19]
 2 โ”‚ % E001: Unexpected Token
 3 โ”‚ \newcommand{\foo} @invalid
   ยท                   โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€
   ยท                       โ•ฐโ”€โ”€ here
 4 โ”‚
   โ•ฐโ”€โ”€โ”€โ”€
  help: Check for invalid characters, malformed commands, or unsupported syntax near the highlighted position.