Magma Lexer Numeric Literal Rules
The Magma lexer groups numeric token definitions under the 'number' state dictionary. It distinguishes hexadecimal integers via r'0[xX][a-fA-F0-9]+' (Number.Hex), binary integers via r'0[bB][01]+' (Number.Bin), floating-point values via r'[0-9]+\.([0-9]+|(?!\.))' (Number.Float), and standard base-10 integers via r'[0-9]+' (Number.Integer).
0
1
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
Learn After
Explain the structure and matching logic of the regular expression
r'[0-9]+\.([0-9]+|(?!\.))'used forNumber.Floatin the Magma lexer.Match each Magma token type with the category of numeric literal it represents.
In the Magma lexer, all numeric token definitions are grouped under the ___ state dictionary.
Arrange the structural components of the regular expression used by the Magma lexer to match binary integer literals (Number.Bin) from left to right.
State the regular expression pattern used by the Magma lexer to match hexadecimal integer tokens, and explain what each component of the pattern matches.