Code

Magma Lexer Comment and Whitespace Handling

In the Pygments Magma lexer, comments and whitespace are parsed under the 'whitespace-comments' state. Standard whitespace is matched by r'\s+', single-line comments are identified with r'//.*', and multi-line comments transition to a 'comment-multiline' state via r'/\*'. Inside the multi-line state, closing tokens r'\*+/' pop the state, non-closing stars r'\*+(?!/)' are matched as comments, and all other characters r'[^*]+' continue the comment.

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