This module implements the lexer for OpenQASM 2.0, which provides a simpler
token set compared to OpenQASM 3.0. The lexer focuses on basic quantum circuit
constructs without the advanced classical programming features of version 3.0.
Key characteristics of OpenQASM 2.0 lexing:
Limited token set: Basic quantum and classical registers only
Simple operators: Basic arithmetic and comparison operators
No control flow: No tokens for loops, conditionals, or functions
Gate-focused: Emphasis on gate definitions and applications
Mathematical functions: Built-in math functions (sin, cos, etc.)
Supported constructs:
Quantum registers (qreg) and classical registers (creg)
Gate definitions and applications
Measurements with arrow notation (->)
Basic arithmetic expressions for gate parameters
Include statements for library files
Example: OpenQASM 2.0 lexing
constlexer = newLexer('qreg q[2]; h q[0]; measure q -> c;'); consttokens = lexer.lex(); // Produces tokens for register declaration, gate, and measurement
OpenQASM 2.0 Lexical Analyzer
This module implements the lexer for OpenQASM 2.0, which provides a simpler token set compared to OpenQASM 3.0. The lexer focuses on basic quantum circuit constructs without the advanced classical programming features of version 3.0.
Key characteristics of OpenQASM 2.0 lexing:
Supported constructs:
qreg
) and classical registers (creg
)->
)Example: OpenQASM 2.0 lexing