Creates a lexer.
The string to lex.
The starting cursor position.
Returns the current line of code where the cursor is located.
The current cursor position in the input string.
The specific line where the cursor is located.
Returns the line number where the current cursor is located.
The current cursor position in the input string.
The line number.
Calling this method lexes the code represented by the provided string.
An array of tokens and their corresponding values.
Retruns an identifier or gate modifier.
Lexes the next token.
The next token and its corresponding value.
Reads a character without advancing the cursor.
Determines whether the next character to process equals a given character.
The given character.
Whether the next character equals the given character.
Reads a character and advances the cursor.
Optional cursor position modifier.
Reads an identifier.
The identifier as a string.
Reds a keyword or identifier. If the character sequence matches a keyword, returns the corresponding token. Otherwise, treats the sequence as an identifier.
The first character of the keyword or identifier.
The corresponding token or identifier.
Reads a numeric value.
The numeric value as a string.
Reads a string literal.
The literal's termination character.
The literal as a string.
Advances the cusor past the next comment.
Advances the cursor past a multiline comment.
Advances the cusor past the next block of whitespace.
Verifies that all appropriate lines end with a semicolon.
A tuple of the status and if False, returns the problematic line.
OpenQASM 3.0 Lexical Analyzer
The main lexer class that processes OpenQASM 3.0 source code character by character and produces a stream of tokens for the parser to consume.
The lexer maintains state including:
Example: Creating and using a lexer