Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pygments/lexers/gcodelexer.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

11 statements  

1""" 

2 pygments.lexers.gcodelexer 

3 ~~~~~~~~~~~~~~~~~~~~~~~~~~ 

4 

5 Lexers for the G Code Language. 

6 

7 :copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS. 

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11from pygments.lexer import RegexLexer, bygroups 

12from pygments.token import Comment, Name, Text, Keyword, Number 

13 

14__all__ = ['GcodeLexer'] 

15 

16 

17class GcodeLexer(RegexLexer): 

18 """ 

19 For gcode source code. 

20 """ 

21 name = 'g-code' 

22 aliases = ['gcode'] 

23 filenames = ['*.gcode'] 

24 url = 'https://en.wikipedia.org/wiki/G-code' 

25 version_added = '2.9' 

26 

27 tokens = { 

28 'root': [ 

29 (r';.*\n', Comment), 

30 (r'^[gmGM]\d{1,4}\s', Name.Builtin), # M or G commands 

31 (r'([^gGmM])([+-]?\d*[.]?\d+)', bygroups(Keyword, Number)), 

32 (r'\s', Text.Whitespace), 

33 (r'.*\n', Text), 

34 ] 

35 }