Code

Magma Lexer String Literal Tokenization

In the Pygments Magma lexer, string literals are handled by transitioning into a dedicated 'string' state upon encountering a double quote ". Inside this state, regular string characters are matched by r'[^\\"]+' yielding String, escaped characters are matched by r'\\.' yielding String.Escape, and a terminating double quote r'"' pops the state with #pop.

0

1

Updated 2026-10-08

Tags

Prep Sessions

Custom Pygments Lexer Engineering for Magma @ University of Michigan - Ann Arbor

Ch.1 Magma Lexer Fundamentals - Custom Pygments Lexer Engineering for Magma @ University of Michigan - Ann Arbor

Lexing Strings, Numbers, and Comments - Custom Pygments Lexer Engineering for Magma @ University of Michigan - Ann Arbor